From 4a77e8874709d7848e4216c59089ccce756f228e Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 21 Sep 2017 11:00:43 +0000 Subject: [PATCH] Tighten tree-ssa-ccp.c:get_value_for_expr condition bit_value_unop and bit_value_binop require constant values to be INTEGER_CSTs: gcc_assert ((rval.lattice_val == CONSTANT && TREE_CODE (rval.value) == INTEGER_CST) || wi::sext (rval.mask, TYPE_PRECISION (TREE_TYPE (rhs))) == -1); However, when deciding whether to record a constant value, the for_bits_p handling in get_value_for_expr used a negative test for ADDR_EXPR: else if (is_gimple_min_invariant (expr) && (!for_bits_p || TREE_CODE (expr) != ADDR_EXPR)) This patch uses a positive test for INTEGER_CST instead. Existing tests showed the need for this once polynomial constants are added. 2017-09-21 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-ssa-ccp.c (get_value_for_expr): Use a positive test for INTEGER_CST rather than a negative test for ADDR_EXPR. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r253056 --- gcc/ChangeLog | 7 +++++++ gcc/tree-ssa-ccp.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3861e6603e3..6f2f3d7a9df 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-09-21 Richard Sandiford + Alan Hayward + David Sherwood + + * tree-ssa-ccp.c (get_value_for_expr): Use a positive test for + INTEGER_CST rather than a negative test for ADDR_EXPR. + 2017-09-21 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 3940d538ca7..9811640c2a5 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -617,7 +617,7 @@ get_value_for_expr (tree expr, bool for_bits_p) } } else if (is_gimple_min_invariant (expr) - && (!for_bits_p || TREE_CODE (expr) != ADDR_EXPR)) + && (!for_bits_p || TREE_CODE (expr) == INTEGER_CST)) { val.lattice_val = CONSTANT; val.value = expr; -- 2.30.2