[forwarded from http://bugs.debian.org/PR492505] works with 4.2 branch, fails with 4.3 branch and trunk, succeeds with -O0 $ gcc-4.3 000.c -c -O1 000.c: In function '_ov_64_seek_lap': 000.c:33: internal compiler error: in set_lattice_value, at tree-ssa-ccp.c:487 Please submit a full bug report, with preprocessed source if appropriate. void _ov_64_seek_lap (void) { unsigned x1, x2, x3; unsigned ltmp_3978_7; unsigned ltmp_3978_7__PHI_TEMPORARY; unsigned ltmp_4011_7__PHI_TEMPORARY; unsigned ltmp_4012_7; signed ltmp_4011_7; if (x1) { if (x2) { goto llvm_cbe__ov_initset_2e_exit; } } while (1) ; llvm_cbe__ov_initset_2e_exit: if (x3) { ltmp_3978_7__PHI_TEMPORARY = 0xffffff7e; goto llvm_cbe_ov_halfrate_p_2e_exit; } ltmp_3978_7__PHI_TEMPORARY = 1; llvm_cbe_ov_halfrate_p_2e_exit: ltmp_3978_7 = ltmp_3978_7__PHI_TEMPORARY; ltmp_4011_7__PHI_TEMPORARY = 0xffffffff; ltmp_4011_7 = ltmp_4011_7__PHI_TEMPORARY; ltmp_4012_7 = ltmp_4011_7 >> ltmp_3978_7; }
Here is a shorter testcase: void _ov_64_seek_lap (void) { _Bool x1, x2, x3; unsigned ltmp_3978_7; unsigned ltmp_3978_7__PHI_TEMPORARY; unsigned ltmp_4011_7__PHI_TEMPORARY; unsigned ltmp_4012_7; signed ltmp_4011_7; if (!x1 || !x2) while (1) ; if (x3) ltmp_3978_7__PHI_TEMPORARY = 0xffffff7e; else ltmp_3978_7__PHI_TEMPORARY = 1; ltmp_3978_7 = ltmp_3978_7__PHI_TEMPORARY; ltmp_4011_7__PHI_TEMPORARY = 0xffffffff; ltmp_4011_7 = ltmp_4011_7__PHI_TEMPORARY; ltmp_4012_7 = ltmp_4011_7 >> ltmp_3978_7; }
link is http://bugs.debian.org/492505
I will have a look.
Minimal testcase: unsigned _ov_64_seek_lap (_Bool x1, _Bool x2, _Bool x3) { unsigned ltmp_3978_7__PHI_TEMPORARY; unsigned ltmp_4011_7__PHI_TEMPORARY; signed ltmp_4011_7; if (!x1 || !x2) while (1) ; if (x3) ltmp_3978_7__PHI_TEMPORARY = 0xffffff7e; else ltmp_3978_7__PHI_TEMPORARY = 1; ltmp_4011_7 = -1; return ltmp_4011_7 >> ltmp_3978_7__PHI_TEMPORARY; }
This is const_binop folding -1 >> -130 to zero and fold_binary -1 >> n to -1. 11458 case RSHIFT_EXPR: 11459 /* Optimize -1 >> x for arithmetic right shifts. */ 11460 if (integer_all_onesp (arg0) && !TYPE_UNSIGNED (type)) 11461 return omit_one_operand (type, arg0, arg1); 11462 /* ... fall through ... */ but this is of course only correct if arg1 is >= 0. I have a patch.
Subject: Bug 38359 Author: rguenth Date: Tue Dec 2 14:49:00 2008 New Revision: 142356 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142356 Log: 2008-12-02 Richard Guenther <rguenther@suse.de> PR tree-optimization/38359 * fold-const.c (fold_binary): Fold -1 >> x to -1 only for non-negative x. * gcc.c-torture/compile/pr38359.c: New testcase. * gcc.c-torture/execute/shiftopt-1.c: Adjust. Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c
Fixed for 4.4.0.
Subject: Bug 38359 Author: rguenth Date: Tue Dec 2 14:55:04 2008 New Revision: 142357 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142357 Log: 2008-12-02 Richard Guenther <rguenther@suse.de> PR tree-optimization/38359 * gcc.c-torture/compile/pr38359.c: New testcase. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr38359.c
GCC 4.3.3 is being released, adjusting target milestone.
Subject: Bug 38359 Author: rguenth Date: Sat Jan 24 23:26:56 2009 New Revision: 143656 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143656 Log: 2009-01-25 Richard Guenther <rguenther@suse.de> Backport from mainline: 2008-12-02 Richard Guenther <rguenther@suse.de> PR tree-optimization/38359 * fold-const.c (fold_binary): Fold -1 >> x to -1 only for non-negative x. * gcc.c-torture/compile/pr38359.c: New testcase. * gcc.c-torture/execute/shiftopt-1.c: Adjust. Added: branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/compile/pr38359.c - copied unchanged from r142357, trunk/gcc/testsuite/gcc.c-torture/compile/pr38359.c Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/fold-const.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c
Fixed.