This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH COMMITTED: Fix PR 31605: Avoid overflow confusion


On Tue, Apr 24, 2007 at 03:26:23PM -0700, Ian Lance Taylor wrote:
> PR tree-optimization/31605 is about a case in which my overflow
> patches to VRP cause it to come up with a bogus range when handling
> CONVERT_EXPR.  I fixed that and also added a check to prevent it from
> happening again.
> 
> Adding that check revealed that there are cases where VRP can get
> confused because it receives a value which happens to equal
> TYPE_MIN_VALUE or TYPE_MAX_VALUE with the TREE_OVERFLOW flag set; this
> is the representation of an overflow infinity.  So I fixed up several
> cases to prevent that from happening.
> 
> Tested with bootstrap and testsuite run and i686-pc-linux-gnu.
> Committed to mainline and 4.2 branch.
> 
> Ian
> 
> 
> gcc/ChangeLog:
> 2007-04-24  Ian Lance Taylor  <iant@google.com>
> 
> 	PR tree-optimization/31605
> 	* tree-vrp.c (set_value_range): Check that min and max are not
> 	both overflow infinities.
[cut]
> 
> gcc/testsuite/ChangeLog:
> 2007-04-24  Ian Lance Taylor  <iant@google.com>
> 
> 	PR tree-optimizatoin/31605
> 	* gcc.c-torture/execute/pr31605.c: New test.

s/optimizatoin/optimization/
 
> Index: tree-vrp.c
> ===================================================================
> --- tree-vrp.c	(revision 124119)
> +++ tree-vrp.c	(working copy)
> @@ -272,6 +272,10 @@ set_value_range (value_range_t *vr, enum
>  
>        cmp = compare_values (min, max);
>        gcc_assert (cmp == 0 || cmp == -1 || cmp == -2);
> +
> +      if (needs_overflow_infinity (TREE_TYPE (min)))
> +	gcc_assert (!is_overflow_infinity (min)
> +		    || !is_overflow_infinity (max));
>      }
>  
>    if (t == VR_UNDEFINED || t == VR_VARYING)

   Having update to revision 124239, this assertion is failing on my 16-bit
x86 port building libgcc:

/home/rask/cvsbuild/gcc/./gcc/xgcc -B/home/rask/cvsbuild/gcc/./gcc/
-nostdinc -B/home/rask/cvsbuild/gcc/ia16-elf/newlib/ -isystem
/home/rask/cvsbuild/gcc/ia16-elf/newlib/targ-include -isystem
/home/rask/cvssrc/gcc/newlib/libc/include -B/usr/local/ia16-elf/bin/
-B/usr/local/ia16-elf/lib/ -isystem /usr/local/ia16-elf/include -isystem
/usr/local/ia16-elf/sys-include -O2 -g -O2 -march=any_8bit -O2 -O2 -g -O2
-DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wwrite-strings
-Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem
./include -g -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc -I. -I.
-I../../.././gcc -I../../../../../cvssrc/gcc/libgcc
-I../../../../../cvssrc/gcc/libgcc/.
-I../../../../../cvssrc/gcc/libgcc/../gcc
-I../../../../../cvssrc/gcc/libgcc/../include -o _si_to_sf.o -MT
_si_to_sf.o -MD -MP -MF _si_to_sf.dep -DFINE_GRAINED_LIBRARIES -DL_si_to_sf
-c ../../.././gcc/fp-bit.c
../../.././gcc/fp-bit.c: In function '__floatsisf':
../../.././gcc/fp-bit.c:1342: internal compiler error: in set_value_range,
at tree-vrp.c:278

The backtrace:
#0  fancy_abort (file=0x882228c "../../../cvssrc/gcc/gcc/tree-vrp.c", line=278, function=0x8822963 "set_value_range")
    at ../../../cvssrc/gcc/gcc/diagnostic.c:655
#1  0x084a7f7d in set_value_range (vr=0xbfcf78ec, t=VR_ANTI_RANGE, min=0xb7d08bec, max=0xb7d08c24, equiv=0x0) at ../../../cvssrc/gcc/gcc/tree-vrp.c:277
#2  0x084b253f in extract_range_from_expr (vr=0xbfcf78ec, expr=0xb7eb69a0) at ../../../cvssrc/gcc/gcc/tree-vrp.c:2440
#3  0x084b4221 in vrp_visit_assignment (stmt=0xb7d08118, output_p=0xbfcf79ac) at ../../../cvssrc/gcc/gcc/tree-vrp.c:4548
#4  0x084b55d9 in vrp_visit_stmt (stmt=0xb7d08118, taken_edge_p=0xbfcf79b0, output_p=0xbfcf79ac) at ../../../cvssrc/gcc/gcc/tree-vrp.c:5072
#5  0x084675f3 in simulate_stmt (stmt=0xb7d08118) at ../../../cvssrc/gcc/gcc/tree-ssa-propagate.c:322
#6  0x08467f0e in ssa_propagate (visit_stmt=0x84b4cd0 <vrp_visit_stmt>, visit_phi=0x84b5800 <vrp_visit_phi_node>)
    at ../../../cvssrc/gcc/gcc/tree-ssa-propagate.c:445
#7  0x084aa968 in execute_vrp () at ../../../cvssrc/gcc/gcc/tree-vrp.c:5963
#8  0x082ae074 in execute_one_pass (pass=0x8852b20) at ../../../cvssrc/gcc/gcc/passes.c:1059

(gdb) frame 1
#1  0x084a7f7d in set_value_range (vr=0xbfcf78ec, t=VR_ANTI_RANGE, min=0xb7d08bec, max=0xb7d08c24, equiv=0x0) at ../../../cvssrc/gcc/gcc/tree-vrp.c:277
277             gcc_assert (!is_overflow_infinity (min)
(gdb) print cmp
$1 = <value optimized out>
(gdb) print *vr
$2 = {type = VR_UNDEFINED, min = 0x0, max = 0x0, equiv = 0x0}
(gdb) call debug_tree(min)
 <integer_cst 0xb7d08bec type <integer_type 0xb7eb38dc SItype> constant invariant public overflow -2147483648>
(gdb) call debug_tree(max)
 <integer_cst 0xb7d08c24 type <integer_type 0xb7eb38dc SItype> constant invariant public overflow -2147483648>
(gdb) call compare_values(min, max)
$3 = 0

(gdb) frame 2
#2  0x084b253f in extract_range_from_expr (vr=0xbfcf78ec, expr=0xb7eb69a0) at ../../../cvssrc/gcc/gcc/tree-vrp.c:2440
2440        set_value_range (vr, vr0.type, min, max, NULL);
(gdb) call debug_tree(expr)
 <negate_expr 0xb7eb69a0
    type <integer_type 0xb7eb38dc SItype public SI
        size <integer_cst 0xb7e1255c constant invariant 32>
        unit size <integer_cst 0xb7e122a0 constant invariant 4>
        align 16 symtab -1211141156 alias set -1 canonical type 0xb7e203cc precision 32 min <integer_cst 0xb7cf6268 -2147483648> max <integer_cst 0xb7cf6310 2147483647>>

    arg 0 <ssa_name 0xb7d0c9f4 type <integer_type 0xb7eb38dc SItype>
        var <parm_decl 0xb7ce5e1c arg_a> def_stmt <gimple_modify_stmt 0xb7d08b44>
        version 51>>

   Any ideas?

-- 
Rask Ingemann Lambertsen


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]