------- Comment #3 from jakub at gcc dot gnu dot org 2010-07-26 12:58 -------
Works if b[] has unsigned int type instead of T.
Sounds like a type mismatch.
The VAR_DECL b has ARRAY_TYPE with T element type and b's CONSTRUCTOR has the
same type, but the values in the constructor doesn't have T type, but unsigned
int:
<constructor 0x7ffff1f2f420
type <array_type 0x7ffff1f23498
type <integer_type 0x7ffff1f232a0 T unsigned SI
size <integer_cst 0x7ffff202d708 constant 32>
unit size <integer_cst 0x7ffff202d410 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x7ffff2042540
precision 32 min <integer_cst 0x7ffff202d730 0> max <integer_cst 0x7ffff202d6e0
4294967295>
pointer_to_this <pointer_type 0x7ffff1f23540>>
SI size <integer_cst 0x7ffff202d708 32> unit size <integer_cst
0x7ffff202d410 4>
align 32 symtab 0 alias set -1 canonical type 0x7ffff1f235e8
domain <integer_type 0x7ffff2055690 type <integer_type 0x7ffff2042000
long unsigned int>
DI
size <integer_cst 0x7ffff202d7d0 constant 64>
unit size <integer_cst 0x7ffff202d7f8 constant 8>
align 64 symtab 0 alias set -1 canonical type 0x7ffff2055690
precision 64 min <integer_cst 0x7ffff202d438 0> max <integer_cst 0x7ffff202d438
0>>>
constant static lngt 1
idx <integer_cst 0x7ffff202db40 type <integer_type 0x7ffff20420a8
bit_size_type> constant 0>
val <integer_cst 0x7ffff202d6e0 type <integer_type 0x7ffff2042540 unsigned
int> constant 4294967295>>
When ccp propagates b[0] into the comparison, the comparison uses T on one side
and unsigned int on the other side. When b has T type, ccp doesn't optimize
the ... < 4294967295 comparison into ... != 4294967295, while when b has
unsigned int type, it does.
T's TYPE_MAIN_VARIANT is unsigned int.
So, it isn't clear if the middle-end is considering the two types as
incompatible or what.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45059