[Bug tree-optimization/95295] g++ produces incorrect code with -O3 for loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 Shubham Narlawar changed: What|Removed |Added CC||gsocshubham at gmail dot com --- Comment #9 from Shubham Narlawar --- I found the ICE - "internal compiler error: in hoist_memory_references, at tree-ssa-loop-im.c:2615" with below testcase when compiled with -Og on trunk. The testcase is obtained by fuzzing function attributes in Csmith - --Testcase--- a, b, c, d, f; **e; g() __attribute__((optimize("Ofast"))); g(h) { int *i = for (; f;) { c = 5; for (; c; c--) { char *j = **e = (h && d) == a; *i = 0; *j = 0; } } } - I see above ICE has been fixed now.
[Bug tree-optimization/95295] g++ produces incorrect code with -O3 for loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 --- Comment #8 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:6c8e16aea85286721eb5689f9bcae09d36003cb1 commit r11-660-g6c8e16aea85286721eb5689f9bcae09d36003cb1 Author: Richard Biener Date: Wed May 27 13:05:07 2020 +0200 tree-optimization/95295 - fix sinking after path merging in new SM code This fixes a missed sinking of remat stores across unrelated stores after merging from different paths. 2020-05-27 Richard Biener PR tree-optimization/95295 * tree-ssa-loop-im.c (sm_seq_valid_bb): Fix sinking after merging stores from paths. * gcc.dg/torture/pr95295-3.c: New testcase.
[Bug tree-optimization/95295] g++ produces incorrect code with -O3 for loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 --- Comment #7 from rguenther at suse dot de --- On Wed, 27 May 2020, vsevolod.livinskij at frtk dot ru wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 > > --- Comment #6 from Vsevolod Livinskiy --- > Thank you for such a quick fix! > > Sorry about duplicates, I saw different assert messages and thought that they > were different bugs. > > I still can see ICE in hoist_memory_references (bug 95283) on trunk. I've > attached the reproducer below. > > Please let me know if it is a different bug, and I'll create another bug > report. Thanks for the report - I have a patch, no need for another bug report.
[Bug tree-optimization/95295] g++ produces incorrect code with -O3 for loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 --- Comment #6 from Vsevolod Livinskiy --- Thank you for such a quick fix! Sorry about duplicates, I saw different assert messages and thought that they were different bugs. I still can see ICE in hoist_memory_references (bug 95283) on trunk. I've attached the reproducer below. Please let me know if it is a different bug, and I'll create another bug report. Error: >$ g++ -c -O3 func.cpp during GIMPLE pass: lim func.cpp: In function ‘void test()’: func.cpp:5:6: internal compiler error: in hoist_memory_references, at tree-ssa-loop-im.c:2615 5 | void test() { | ^~~~ 0x82318c hoist_memory_references gcc_src/gcc/tree-ssa-loop-im.c:2615 0x82318c store_motion_loop gcc_src/gcc/tree-ssa-loop-im.c:2912 0x123853a do_store_motion gcc_src/gcc/tree-ssa-loop-im.c:2937 0x123853a tree_ssa_lim gcc_src/gcc/tree-ssa-loop-im.c:3156 0x123853a execute gcc_src/gcc/tree-ssa-loop-im.c:3206 Reproducer: extern short var_15, var_20; extern int var_18, var_21, var_23; extern bool arr_2[]; extern long arr_3[]; void test() { var_20 = 1; for (int a = 0; a < 12; a += 2) for (short b = 0; b < 8; b += 2) { arr_2[b] = var_21 = var_18 ? var_15 : 0; arr_3[b] = 8569; } var_23 = -1096835496; } GCC version: 11.0.0 (adad99eb906164af7d2b398ad7e430aebe3adeb4)
[Bug tree-optimization/95295] g++ produces incorrect code with -O3 for loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 Richard Biener changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #5 from Richard Biener --- Fixed.
[Bug tree-optimization/95295] g++ produces incorrect code with -O3 for loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 --- Comment #4 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:4acca1c0635dfa43cd8c4bfe2b22e17909fc23a3 commit r11-609-g4acca1c0635dfa43cd8c4bfe2b22e17909fc23a3 Author: Richard Biener Date: Mon May 25 10:09:44 2020 +0200 tree-optimization/95295 - fix wrong-code with SM We failed to compare the rematerialized store values when merging paths after walking PHIs. 2020-05-25 Richard Biener PR tree-optimization/95295 * tree-ssa-loop-im.c (sm_seq_valid_bb): Compare remat stores RHSes and drop to full sm_other if they are not equal. * gcc.dg/torture/pr95295-1.c: New testcase. * gcc.dg/torture/pr95295-2.c: Likewise. * gcc.dg/torture/pr95283.c: Likewise.
[Bug tree-optimization/95295] g++ produces incorrect code with -O3 for loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 --- Comment #3 from Richard Biener --- *** Bug 95281 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/95295] g++ produces incorrect code with -O3 for loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 --- Comment #2 from Richard Biener --- *** Bug 95283 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/95295] g++ produces incorrect code with -O3 for loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95295 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2020-05-25 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Richard Biener --- Confirmed, mine.