From PR38572, but unrelated to it: void f (long long int p) { int x; static unsigned char g; long long int min = -9223372036854775807LL - 1; g = 1; x = (signed char) (g | 249) / 4; if (p >= min - (long long int) x) p = 1; if (p) abort (); } gives small.c: In function 'f': small.c:3: internal compiler error: in set_value_range, at tree-vrp.c:398 Note that after FRE the code becomes the simpler void f (long long int p) { long long int min = 9223372036854775807LL + 2; /*0x7fffffffffffffff */ if (min <= p) p = 1; if (p) abort (); } but this does not ICE because in this testcase the "min <= p" is changed to "p != min - 1" by the first CCP pass, so this is also a missed folding in FRE. I'm looking at the VRP failure though.
Can anyone check if this is a regression, and if so from which version?
Actually, there is no overflow in -9223372036854775807LL - 1 so this is a third bug. :-)
ah no there's no overflow bit on min
In PRE there is a fold_convert_const_int_from_int call simplifying "(signed char) 249" to -7, but setting the TREE_OVERFLOW flag in the meanwhile. I don't think it makes sense to set the overflow flag on a NOP: * `The result of, or the signal raised by, converting an integer to a signed integer type when the value cannot be represented in an object of that type (C90 6.2.1.2, C99 6.3.1.3).' For conversion to a type of width N, the value is reduced modulo 2^N to be within range of the type; no signal is raised. (Integers implementation, from the gcc manual).
Subject: Re: ICE in set_value_range, at tree-vrp.c:398 Sent from my iPhone On Jan 22, 2009, at 1:00 AM, "bonzini at gnu dot org" <gcc-bugzilla@gcc.gnu.org > wrote: > > > ------- Comment #4 from bonzini at gnu dot org 2009-01-22 09:00 > ------- > In PRE there is a fold_convert_const_int_from_int call simplifying > "(signed > char) 249" to -7, but setting the TREE_OVERFLOW flag in the > meanwhile. I > don't think it makes sense to set the overflow flag on a NOP: Yes but changing that right now opens lots of bags of worms. It has been tried before. The simple way to fix this is in pre unset TREE_OVERFLOW because at this point in the IR it does not matter. I hope someone would change vrp to do the correct thing but I guess that won't happen any time soon. Thanks, Andrew Pinski > > > * `The result of, or the signal raised by, converting an integer > to a > signed integer type when the value cannot be represented in an > object of that type (C90 6.2.1.2, C99 6.3.1.3).' > > For conversion to a type of width N, the value is reduced modulo > 2^N to be within range of the type; no signal is raised. > > (Integers implementation, from the gcc manual). > > > -- > > bonzini at gnu dot org changed: > > What |Removed |Added > --- > --- > ---------------------------------------------------------------------- > CC| |rguenth at gcc dot > gnu dot > | |org > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38932 >
Subject: Re: ICE in set_value_range, at tree-vrp.c:398 On Thu, 22 Jan 2009, bonzini at gnu dot org wrote: > ------- Comment #4 from bonzini at gnu dot org 2009-01-22 09:00 ------- > In PRE there is a fold_convert_const_int_from_int call simplifying "(signed > char) 249" to -7, but setting the TREE_OVERFLOW flag in the meanwhile. I > don't think it makes sense to set the overflow flag on a NOP: > > * `The result of, or the signal raised by, converting an integer to a > signed integer type when the value cannot be represented in an > object of that type (C90 6.2.1.2, C99 6.3.1.3).' > > For conversion to a type of width N, the value is reduced modulo > 2^N to be within range of the type; no signal is raised. > > (Integers implementation, from the gcc manual). Correct. PRE should make sure to clear TREE_OVERFLOW, like CCP for example does. A more general solution unfortunately opens too many cans of worms. Richard.
mine.
Fixing FRE still causes an ICE for this: /* { dg-do compile } */ /* { dg-options "-O2 --std=gnu99" } */ /* This variable needed only to exercise FRE instead of CCP. */ unsigned char g; extern void abort(); void f (long long int p) { g = 255; /* { dg-warning "constant is" "" { target *-*-* } 14 } */ /* { dg-warning "overflow" "" { target *-*-* } 14 } */ if (p >= -9223372036854775808LL - (signed char) g) p = 1; if (p) abort (); } Should I create a separate bug and submit what I have?
Subject: Re: [4.4 Regression] ICE in set_value_range, at tree-vrp.c:398 On Thu, 22 Jan 2009, bonzini at gnu dot org wrote: > ------- Comment #8 from bonzini at gnu dot org 2009-01-22 12:10 ------- > Fixing FRE still causes an ICE for this: > > /* { dg-do compile } */ > /* { dg-options "-O2 --std=gnu99" } */ > > /* This variable needed only to exercise FRE instead of CCP. */ > unsigned char g; > > extern void abort(); > > void f (long long int p) > { > g = 255; > /* { dg-warning "constant is" "" { target *-*-* } 14 } */ > /* { dg-warning "overflow" "" { target *-*-* } 14 } */ > if (p >= -9223372036854775808LL - (signed char) g) > p = 1; > > if (p) > abort (); > } > > Should I create a separate bug and submit what I have? Yes. Thanks, Richard.
It is caused by revision 126434: http://gcc.gnu.org/ml/gcc-cvs/2007-07/msg00290.html
Subject: Re: [4.3/4.4 Regression] ICE in set_value_range, at tree-vrp.c:398 Uh, well, that would be tricky since none of this code still exists in 4.4.0 On Thu, Jan 22, 2009 at 11:09 AM, hjl dot tools at gmail dot com <gcc-bugzilla@gcc.gnu.org> wrote: > > > ------- Comment #10 from hjl dot tools at gmail dot com 2009-01-22 16:09 ------- > It is caused by revision 126434: > > http://gcc.gnu.org/ml/gcc-cvs/2007-07/msg00290.html > > > -- > > hjl dot tools at gmail dot com changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |dberlin at gcc dot gnu dot > | |org > Known to fail|4.4.0 |4.3.3 4.4.0 > Summary|[4.4 Regression] ICE in |[4.3/4.4 Regression] ICE in > |set_value_range, at tree- |set_value_range, at tree- > |vrp.c:398 |vrp.c:398 > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38932 > > ------- You are receiving this mail because: ------- > You are on the CC list for the bug, or are watching someone who is. >
Subject: Bug 38932 Author: bonzini Date: Fri Jan 23 15:57:19 2009 New Revision: 143588 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143588 Log: 2008-01-23 Paolo Bonzini <bonzini@gnu.org> PR tree-optimization/38932 * fold-const.c (fold_unary_no_overflow): New. * tree.h (fold_unary_no_overflow): Declare. * tree-ssa-ccp.c (ccp_fold): Use fold_unary_no_overflow. * tree-ssa-sccvn.c (visit_reference_op_load, simplify_unary_expression): Likewise. testsuite: 2008-01-23 Paolo Bonzini <bonzini@gnu.org> PR tree-optimization/38932 * gcc.dg/pr38932.c: New. Added: trunk/gcc/testsuite/gcc.dg/pr38932.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-ccp.c trunk/gcc/tree-ssa-sccvn.c trunk/gcc/tree.h
Fixed on the trunk.
Regarding the target milestone, you mean I should apply a 4.3 patch before the release goes out, too? (I'm currently regtesting it).
Subject: Re: [4.3 Regression] ICE in set_value_range, at tree-vrp.c:398 On Sat, 24 Jan 2009, bonzini at gnu dot org wrote: > ------- Comment #14 from bonzini at gnu dot org 2009-01-24 08:59 ------- > Regarding the target milestone, you mean I should apply a 4.3 patch before the > release goes out, too? (I'm currently regtesting it). No. Richard.
changing milestone appropriately then, it did sound strange.
Subject: Re: [4.3 Regression] ICE in set_value_range, at tree-vrp.c:398 On Sat, 24 Jan 2009, bonzini at gnu dot org wrote: > ------- Comment #16 from bonzini at gnu dot org 2009-01-24 09:54 ------- > changing milestone appropriately then, it did sound strange. Well, we will bump the target milestone of all bugs appropriately after the release. So it wasn't inappropriate but just followed policy. Richard.
Subject: Bug 38932 Author: bonzini Date: Mon Jan 26 15:54:18 2009 New Revision: 143677 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143677 Log: gcc: 2008-01-26 Paolo Bonzini <bonzini@gnu.org> PR tree-optimization/38932 * fold-const.c (fold_unary_ignore_overflow): New. * tree.h (fold_unary_ignore_overflow): Declare. * tree-ssa-ccp.c (ccp_fold): Use fold_unary_ignore_overflow. * tree-ssa-sccvn.c (simplify_unary_expression): Likewise. gcc/testsuite: 2008-01-26 Paolo Bonzini <bonzini@gnu.org> PR tree-optimization/38932 * gcc.dg/pr38932.c: New. Added: branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/pr38932.c - copied unchanged from r143588, trunk/gcc/testsuite/gcc.dg/pr38932.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/tree-ssa-ccp.c branches/gcc-4_3-branch/gcc/tree-ssa-sccvn.c branches/gcc-4_3-branch/gcc/tree.h
fixed on 4.3 branch too.