------- Comment #18 from rguenth at gcc dot gnu dot org 2007-01-05 13:45 ------- And we get that because for the COMPONENT_REF
D.1741.typeD.1734 we have <component_ref 0xb7c3d168 type <integer_type 0xb7c401cc short int HI size <integer_cst 0xb7c2e300 constant invariant 16> unit size <integer_cst 0xb7c2e318 constant invariant 2> align 16 symtab 0 alias set -1 precision 16 min <integer_cst 0xb7c2e2a0 -32768> max <integer_cst 0xb7c2e2d0 32767>> arg 0 <var_decl 0xb7c3b2c0 D.1741 ....> arg 1 <field_decl 0xb7cd38a0 type type <integer_type 0xb7c40284 int sizes-gimplified public SI size <integer_cst 0xb7c2e3f0 32> unit size <integer_cst 0xb7c2e180 4> align 32 symtab 0 alias set -1 precision 32 min <integer_cst 0xb7c2e3a8 -2147483648> max <integer_cst 0xb7c2e3c0 2147483647> pointer_to_this <pointer_type 0xb7c40c38>> .....> also mismatched types (it should have int type). Which we get starting from tree.c:get_narrower () via #0 0x08707d25 in get_narrower (op=0xb7c3f118, unsignedp_ptr=0xbfa90828) at /home/richard/src/gcc-4_1-branch/gcc/tree.c:5488 #1 0x08232cff in shorten_compare (op0_ptr=0xbfa90a40, op1_ptr=0xbfa90a3c, restype_ptr=0xbfa90a38, rescode_ptr=0xbfa90a34) at /home/richard/src/gcc-4_1-branch/gcc/c-common.c:1956 #2 0x0818b5ba in build_binary_op (code=EQ_EXPR, orig_op0=0xb7c3f118, orig_op1=0xb7c3f140, convert_p=1) at /home/richard/src/gcc-4_1-branch/gcc/cp/typeck.c:3435 5483 && (first || uns == DECL_UNSIGNED (TREE_OPERAND (op, 1))) 5484 && type != 0) 5485 { 5486 if (first) 5487 uns = DECL_UNSIGNED (TREE_OPERAND (op, 1)); 5488 win = build3 (COMPONENT_REF, type, TREE_OPERAND (op, 0), 5489 TREE_OPERAND (op, 1), NULL_TREE); 5490 TREE_SIDE_EFFECTS (win) = TREE_SIDE_EFFECTS (op); 5491 TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op); 5492 } using fold_convert here results in identical code and we generate the following gimple: int f() () { int D.1742; struct Geometry D.1741; struct Geometry D.1743; short int D.1744; int D.1745; short int D.1746; short int D.1747; struct Geometry test; D.1743 = get (); D.1741 = D.1743; D.1744 = D.1741.type; D.1745 = (int) D.1744; D.1746 = (short int) D.1745; D.1747 = test.type; D.1742 = D.1746 == D.1747; return D.1742; } and optimized: int f() () { int SR.40; short int SR.39; short int test$type; struct Geometry test; short int D.1747; short int D.1746; int D.1745; short int D.1744; struct Geometry D.1743; struct Geometry D.1741; int D.1742; <bb 0>: return (short int) SR.40 == test$type; } Recent mainline does gimple: int f() () { int D.2084; struct Geometry D.2083; short int D.2085; short int D.2086; struct Geometry test; D.2083 = get () [return slot optimization]; D.2085 = D.2083.type; D.2086 = test.type; D.2084 = D.2085 == D.2086; return D.2084; } and optimized: Analyzing Edge Insertions. int f() () { short int SR.35; short int test$type; <bb 2>: return SR.35 == test$type; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27826