From 01b57ebf58b8cc0d16db827d1d9aa5f10da23cce Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 18 Sep 2019 09:44:06 +0000 Subject: [PATCH] Make get_value_for_expr check for INTEGER_CSTs CONSTANT lattice values are symbolic constants rather than compile-time constants, so among other things can be POLY_INT_CSTs. This patch fixes a case in which we assumed all CONSTANTs were either ADDR_EXPRs or INTEGER_CSTs. This is tested by later SVE patches. 2019-09-18 Richard Sandiford gcc/ * tree-ssa-ccp.c (get_value_for_expr): Check whether CONSTANTs are INTEGER_CSTs. From-SVN: r275871 --- gcc/ChangeLog | 5 +++++ gcc/tree-ssa-ccp.c | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2842a7f4cfc..57850818f28 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-09-18 Richard Sandiford + + * tree-ssa-ccp.c (get_value_for_expr): Check whether CONSTANTs + are INTEGER_CSTs. + 2019-09-18 Richard Sandiford * gimplify.c (gimplify_decl_expr): Use poly_int_tree_p instead diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 5af3810e8f0..311918bfaf7 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -615,9 +615,17 @@ get_value_for_expr (tree expr, bool for_bits_p) val.mask = -1; } if (for_bits_p - && val.lattice_val == CONSTANT - && TREE_CODE (val.value) == ADDR_EXPR) - val = get_value_from_alignment (val.value); + && val.lattice_val == CONSTANT) + { + if (TREE_CODE (val.value) == ADDR_EXPR) + val = get_value_from_alignment (val.value); + else if (TREE_CODE (val.value) != INTEGER_CST) + { + val.lattice_val = VARYING; + val.value = NULL_TREE; + val.mask = -1; + } + } /* Fall back to a copy value. */ if (!for_bits_p && val.lattice_val == VARYING -- 2.30.2