The following fixes PR65788. We need to use UNDEFINED whenever possible to not get spurious invalid lattice transitions later.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2015-04-21 Richard Biener <rguent...@suse.de> PR tree-optimization/65788 * tree-ssa-ccp.c (evaluate_stmt): Evaluate to UNDEFINED early. Index: gcc/tree-ssa-ccp.c =================================================================== *** gcc/tree-ssa-ccp.c (revision 222227) --- gcc/tree-ssa-ccp.c (working copy) *************** evaluate_stmt (gimple stmt) *** 1756,1761 **** --- 1756,1769 ---- val.mask = 0; } } + /* If the statement result is likely UNDEFINED, make it so. */ + else if (likelyvalue == UNDEFINED) + { + val.lattice_val = UNDEFINED; + val.value = NULL_TREE; + val.mask = 0; + return val; + } /* Resort to simplification for bitwise tracking. */ if (flag_tree_bit_ccp *************** evaluate_stmt (gimple stmt) *** 1890,1896 **** if (flag_tree_bit_ccp && ((is_constant && TREE_CODE (val.value) == INTEGER_CST) ! || (!is_constant && likelyvalue != UNDEFINED)) && gimple_get_lhs (stmt) && TREE_CODE (gimple_get_lhs (stmt)) == SSA_NAME) { --- 1898,1904 ---- if (flag_tree_bit_ccp && ((is_constant && TREE_CODE (val.value) == INTEGER_CST) ! || !is_constant) && gimple_get_lhs (stmt) && TREE_CODE (gimple_get_lhs (stmt)) == SSA_NAME) { *************** evaluate_stmt (gimple stmt) *** 1918,1939 **** } } if (!is_constant) { ! /* The statement produced a nonconstant value. If the statement ! had UNDEFINED operands, then the result of the statement ! should be UNDEFINED. Otherwise, the statement is VARYING. */ ! if (likelyvalue == UNDEFINED) ! { ! val.lattice_val = likelyvalue; ! val.mask = 0; ! } ! else ! { ! val.lattice_val = VARYING; ! val.mask = -1; ! } ! val.value = NULL_TREE; } --- 1926,1936 ---- } } + /* The statement produced a nonconstant value. */ if (!is_constant) { ! val.lattice_val = VARYING; ! val.mask = -1; val.value = NULL_TREE; }