Hello,with POINTER_DIFF_EXPR, checking if the result is integral does not imply that the arguments are as well, so this check needed a tweak.
Bootstrap+regtest on gcc112, pre-approved by Richard. 2017-11-22 Marc Glisse <marc.gli...@inria.fr> PR tree-optimization/83104 gcc/ * vr-values.c (simplify_stmt_using_ranges): Check integral argument, not result. gcc/testsuite/ * gcc.c-torture/compile/pr83104.c: New file. -- Marc Glisse
Index: gcc/testsuite/gcc.c-torture/compile/pr83104.c =================================================================== --- gcc/testsuite/gcc.c-torture/compile/pr83104.c (nonexistent) +++ gcc/testsuite/gcc.c-torture/compile/pr83104.c (revision 255068) @@ -0,0 +1,5 @@ +int *a; +int foo() { + if (a && a - (int *)0 > 0) + return 0; +} Index: gcc/vr-values.c =================================================================== --- gcc/vr-values.c (revision 255067) +++ gcc/vr-values.c (revision 255068) @@ -4084,21 +4084,21 @@ vr_values::simplify_stmt_using_ranges (g To: LHS = VAR == VAL1 ? (CST BINOP VAL1) : (CST BINOP VAL2) Also handles: LHS = VAR BINOP CST Where VAR is two-valued and LHS is used in GIMPLE_COND only To: LHS = VAR == VAL1 ? (VAL1 BINOP CST) : (VAL2 BINOP CST) */ if (TREE_CODE_CLASS (rhs_code) == tcc_binary - && INTEGRAL_TYPE_P (TREE_TYPE (lhs)) + && INTEGRAL_TYPE_P (TREE_TYPE (rhs1)) && ((TREE_CODE (rhs1) == INTEGER_CST && TREE_CODE (rhs2) == SSA_NAME) || (TREE_CODE (rhs2) == INTEGER_CST && TREE_CODE (rhs1) == SSA_NAME)) && single_imm_use (lhs, &use_p, &use_stmt) && gimple_code (use_stmt) == GIMPLE_COND) { tree new_rhs1 = NULL_TREE; tree new_rhs2 = NULL_TREE;