Hi, This is a case of NOP_EXPR and CONVERT_EXPR not compared equal in operand_equal_p, resulting in below two nodes are considered different:
NODE 0: <convert_expr 0xb72ddb04 type <integer_type 0xb74602a0 short int sizes-gimplified public HI size <integer_cst 0xb744e7c4 constant 16> unit size <integer_cst 0xb744e7e0 constant 2> align 16 symtab 0 alias set 4 canonical type 0xb74602a0 precision 16 min <integer_cst 0xb744e770 -32768> max <integer_cst 0xb744e78c 32767> context <translation_unit_decl 0xb760dd80 D.6120> pointer_to_this <pointer_type 0xb7241600>> arg 0 <ssa_name 0xb72882f8 type <integer_type 0xb7460420 long int sizes-gimplified public SI size <integer_cst 0xb744e55c constant 32> unit size <integer_cst 0xb744e578 constant 4> align 32 symtab 0 alias set 5 canonical type 0xb7460420 precision 32 min <integer_cst 0xb744e888 -2147483648> max <integer_cst 0xb744e8a4 2147483647> context <translation_unit_decl 0xb760dd80 D.6120> pointer_to_this <pointer_type 0xb74677e0>> visiteddef_stmt _23 = *_22; version 23>> NODE 1: <nop_expr 0xb72e1b54 type <integer_type 0xb74602a0 short int sizes-gimplified public HI size <integer_cst 0xb744e7c4 constant 16> unit size <integer_cst 0xb744e7e0 constant 2> align 16 symtab 0 alias set 4 canonical type 0xb74602a0 precision 16 min <integer_cst 0xb744e770 -32768> max <integer_cst 0xb744e78c 32767> context <translation_unit_decl 0xb760dd80 D.6120> pointer_to_this <pointer_type 0xb7241600>> arg 0 <ssa_name 0xb72882f8 type <integer_type 0xb7460420 long int sizes-gimplified public SI size <integer_cst 0xb744e55c constant 32> unit size <integer_cst 0xb744e578 constant 4> align 32 symtab 0 alias set 5 canonical type 0xb7460420 precision 32 min <integer_cst 0xb744e888 -2147483648> max <integer_cst 0xb744e8a4 2147483647> context <translation_unit_decl 0xb760dd80 D.6120> pointer_to_this <pointer_type 0xb74677e0>> visiteddef_stmt _23 = *_22; version 23>> This patch fixes the problem. Please refer to http://gcc.gnu.org/ml/gcc/2013-05/msg00199.html for more information. Bootstrap and test on x86 and cortex-a15. Is it OK? Thanks. bin 2013-06-13 Bin Cheng <bin.ch...@arm.com> * fold-const.c (operand_equal_p): Consider NOP_EXPR and CONVERT_EXPR as equal nodes.
Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 199844) +++ gcc/fold-const.c (working copy) @@ -2473,9 +2473,13 @@ operand_equal_p (const_tree arg0, const_tree arg1, } if (TREE_CODE (arg0) != TREE_CODE (arg1) - /* This is needed for conversions and for COMPONENT_REF. - Might as well play it safe and always test this. */ - || TREE_CODE (TREE_TYPE (arg0)) == ERROR_MARK + /* NOP_EXPR and CONVERT_EXPR are considered equal. */ + && !(CONVERT_EXPR_P (arg0) && CONVERT_EXPR_P (arg1))) + return 0; + + /* This is needed for conversions and for COMPONENT_REF. + Might as well play it safe and always test this. */ + if (TREE_CODE (TREE_TYPE (arg0)) == ERROR_MARK || TREE_CODE (TREE_TYPE (arg1)) == ERROR_MARK || TYPE_MODE (TREE_TYPE (arg0)) != TYPE_MODE (TREE_TYPE (arg1))) return 0;