[Bug tree-optimization/85529] [7/8/9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85529 --- Comment #9 from Jakub Jelinek --- Author: jakub Date: Fri Apr 27 07:11:44 2018 New Revision: 259697 URL: https://gcc.gnu.org/viewcvs?rev=259697=gcc=rev Log: PR tree-optimization/85529 * tree-ssa-reassoc.c (optimize_range_tests_var_bound): Add FIRST_BB argument. Don't call get_nonzero_bits if opcode is ERROR_MARK_NODE, rhs2 def stmt's bb is dominated by first_bb and it isn't an obvious zero extension or masking of the MSB bit. (optimize_range_tests): Add FIRST_BB argument, pass it through to optimize_range_tests_var_bound. (maybe_optimize_range_tests, reassociate_bb): Adjust optimize_range_tests callers. * gcc.c-torture/execute/pr85529-1.c: New test. * gcc.c-torture/execute/pr85529-2.c: New test. * gcc.dg/pr85529.c: New test. Added: branches/gcc-8-branch/gcc/testsuite/gcc.c-torture/execute/pr85529-1.c branches/gcc-8-branch/gcc/testsuite/gcc.c-torture/execute/pr85529-2.c branches/gcc-8-branch/gcc/testsuite/gcc.dg/pr85529.c Modified: branches/gcc-8-branch/gcc/ChangeLog branches/gcc-8-branch/gcc/testsuite/ChangeLog branches/gcc-8-branch/gcc/tree-ssa-reassoc.c
[Bug tree-optimization/85529] [7/8/9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85529 --- Comment #8 from Jakub Jelinek --- Author: jakub Date: Fri Apr 27 07:09:51 2018 New Revision: 259696 URL: https://gcc.gnu.org/viewcvs?rev=259696=gcc=rev Log: PR tree-optimization/85529 * tree-ssa-reassoc.c (optimize_range_tests_var_bound): Add FIRST_BB argument. Don't call get_nonzero_bits if opcode is ERROR_MARK_NODE, rhs2 def stmt's bb is dominated by first_bb and it isn't an obvious zero extension or masking of the MSB bit. (optimize_range_tests): Add FIRST_BB argument, pass it through to optimize_range_tests_var_bound. (maybe_optimize_range_tests, reassociate_bb): Adjust optimize_range_tests callers. * gcc.c-torture/execute/pr85529-1.c: New test. * gcc.c-torture/execute/pr85529-2.c: New test. * gcc.dg/pr85529.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/execute/pr85529-1.c trunk/gcc/testsuite/gcc.c-torture/execute/pr85529-2.c trunk/gcc/testsuite/gcc.dg/pr85529.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-reassoc.c
[Bug tree-optimization/85529] [7/8/9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85529 Jakub Jelinek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #7 from Jakub Jelinek --- Created attachment 44026 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44026=edit gcc8-pr85529.patch Untested fix.
[Bug tree-optimization/85529] [7/8/9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85529 --- Comment #6 from Jakub Jelinek --- And finally a testcase that is miscompiled on 7.x, starting with r240858: /* PR tree-optimization/85529 */ /* { dg-do run } */ /* { dg-options "-O2 -fno-ssa-phiopt" } */ __attribute__((noinline, noclone)) int foo (int x) { x &= 31; x -= 25; x *= 2; if (x < 0) return 1; int y = x >> 2; if (x >= y) return 1; return 0; } int main () { int i; for (i = 0; i < 63; i++) if (foo (i) != 1) __builtin_abort (); return 0; }
[Bug tree-optimization/85529] [7/8/9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85529 --- Comment #5 from Jakub Jelinek --- Slightly tweaked testcase: struct S { int a; }; int b, c = 1, d, e, f; static int g; volatile struct S s; signed char foo (signed char i, int j) { return i < 0 ? i : i << j; } int main () { signed char k = -83; if (!d) goto L; k = e || f; L: for (; b < 1; b++) s.a != (k < foo (k, 2) && (c = k = g)); if (c != 1) __builtin_abort (); return 0; } Another testcase, that started being miscompiled with r255387 is: __attribute__((noipa)) int foo (int x) { x &= 63; x -= 50; x |= 1; if (x < 0) return 1; int y = x >> 2; if (x >= y) return 1; return 0; } int main () { int i; for (i = 0; i < 63; i++) if (foo (i) != 1) __builtin_abort (); return 0; }
[Bug tree-optimization/85529] [7/8/9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85529 Richard Biener changed: What|Removed |Added Target Milestone|8.0 |7.4 Summary|[8/9 Regression] wrong code |[7/8/9 Regression] wrong |at -O2 and -O3 on |code at -O2 and -O3 on |x86_64-linux-gnu|x86_64-linux-gnu --- Comment #4 from Richard Biener --- The issue is latent on the GCC 7 branch.