Seen on Ubuntu Hardy. regehr@john-home:~/volatile/tmp179$ current-gcc -O3 -c small.c small.c: In function ‘box’: small.c:29:3: warning: overflow in implicit constant conversion small.c:31:1: internal compiler error: in simplify_subreg, at simplify-rtx.c:4981 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. regehr@john-home:~/volatile/tmp179$ current-gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../configure --prefix=/home/regehr/z/tmp/gcc-r150096-install --program-prefix=r150096- --enable-languages=c,c++ Thread model: posix gcc version 4.5.0 20090726 (experimental) (GCC) regehr@john-home:~/volatile/tmp179$ cat small.c int foo (int _left, int _right) { return 1 >= 1 * 8 || 9223372036854775807LL >> _right ? : 0; } signed char bar (signed char _ui1, signed char _ui2) { return _ui1; } signed char baz (int _ui1, signed char _ui2) { return _ui1 * _ui2; } volatile signed char g_35; int func_16 (int p_17, signed char p_19) { if (foo (1, bar (p_17, 1))) if (g_35) { } return 0; } void box (signed char p_13, signed char p_14) { signed char l_133 = 0xF5C80580; func_16 (baz (l_133, g_35), 1); }
*** Bug 40862 has been marked as a duplicate of this bug. ***
Confirmed. Shorter testcase (crashes with "-O -m32" on x86_64-unknown-linux-gnu): ================================== int foo(volatile int i) { return (1LL >> 128 * i) && i; } ================================== The crash already occurs with GCC 4.4.0, but not with GCC 4.3.x.
Backtrace with current SVN: #1 0x000000000076991d in simplify_subreg (outermode=SImode, op=0x7ffff28a68a0, innermode=DImode, byte=4294967280) at ../../gcc-svn/trunk/gcc/simplify-rtx.c:4982 #2 0x0000000000769b3e in simplify_gen_subreg (outermode=12901752, op=0x1376, innermode=12905920, byte=4) at ../../gcc-svn/trunk/gcc/simplify-rtx.c:5286 #3 0x0000000000769b3e in simplify_gen_subreg (outermode=12901752, op=0x1376, innermode=12905920, byte=4) at ../../gcc-svn/trunk/gcc/simplify-rtx.c:5286 #4 0x0000000000b07848 in if_then_else_cond (x=0x7ffff28a69c0, ptrue=0x7fffffffdb90, pfalse=0x7fffffffdb80) at ../../gcc-svn/trunk/gcc/combine.c:7979 #5 0x0000000000b07619 in if_then_else_cond (x=0x7ffff28a6a20, ptrue=0x7fffffffdc28, pfalse=0x7fffffffdc38) at ../../gcc-svn/trunk/gcc/combine.c:7864 #6 0x0000000000b0f037 in combine_simplify_rtx (x=0x7ffff28a6a20, op0_mode=SImode, in_dest=0) at ../../gcc-svn/trunk/gcc/combine.c:4629 #7 0x0000000000b115ed in subst (x=0x8, from=<value optimized out>, to=0x7ffff28a68e0, in_dest=0, unique_copy=17) at ../../gcc-svn/trunk/gcc/combine.c:4568 #8 0x0000000000b113a8 in subst (x=0x7ffff28a6a40, from=0x7ffff28a6860, to=0x7ffff28a68e0, in_dest=<value optimized out>, ---Type <return> to continue, or q <return> to quit--- unique_copy=<value optimized out>) at ../../gcc-svn/trunk/gcc/combine.c:4506 #9 0x0000000000b1129a in subst (x=0x7ffff2a67d10, from=0x7ffff28a6860, to=0x7ffff28a68e0, in_dest=<value optimized out>, unique_copy=<value optimized out>) at ../../gcc-svn/trunk/gcc/combine.c:4433 "byte" argument, passed to simplify_subreg in frame #1 is a bit high for current state of the art.
Patch in testing: --cut here-- Index: simplify-rtx.c =================================================================== --- simplify-rtx.c (revision 151142) +++ simplify-rtx.c (working copy) @@ -5263,6 +5263,7 @@ simplify_subreg (enum machine_mode outer && GET_MODE_BITSIZE (innermode) >= (2 * GET_MODE_BITSIZE (outermode)) && CONST_INT_P (XEXP (op, 1)) && (INTVAL (XEXP (op, 1)) & (GET_MODE_BITSIZE (outermode) - 1)) == 0 + && INTVAL (XEXP (op, 1)) >= 0 && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (innermode) && byte == subreg_lowpart_offset (outermode, innermode)) { --cut here--
Subject: Bug 40861 Author: uros Date: Thu Aug 27 20:54:28 2009 New Revision: 151149 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151149 Log: PR rtl-optimization/40861 * simplify-rtx.c (simplify_subreg): Do not call simplify_gen_subreg to extract word from a multi-word subreg for negative byte positions. testsuite/ChangeLog: PR rtl-optimization/40861 * gcc.dg/pr40861.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr40861.c Modified: trunk/gcc/ChangeLog trunk/gcc/simplify-rtx.c trunk/gcc/testsuite/ChangeLog
Fixed for GCC 4.5.0. Uros, are you going to backport the fix to the 4.4 branch?
Subject: Bug 40861 Author: uros Date: Mon Sep 7 20:25:52 2009 New Revision: 151489 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151489 Log: Backport from mainline: 2009-08-27 Uros Bizjak <ubizjak@gmail.com> PR rtl-optimization/40861 * simplify-rtx.c (simplify_subreg): Do not call simplify_gen_subreg to extract word from a multi-word subreg for negative byte positions. testsuite/ChangeLog: Backport from mainline: 2009-08-27 Uros Bizjak <ubizjak@gmail.com> PR rtl-optimization/40861 * gcc.dg/pr40861.c: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr40861.c Modified: branches/gcc-4_4-branch/gcc/ChangeLog branches/gcc-4_4-branch/gcc/simplify-rtx.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
Thanks for the reminder, I forgot on this patch... Fixed.