Message ID | 87lgl91sd0.fsf@linaro.org |
---|---|
State | New |
Headers | show |
Series | Tighten tree-ssa-ccp.c:get_value_for_expr condition | expand |
On Wed, Sep 20, 2017 at 2:12 PM, Richard Sandiford <richard.sandiford@linaro.org> wrote: > 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. > > Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linus-gnu. > OK to install? Ok. Richard. > Richard > > > 2017-09-20 Richard Sandiford <richard.sandiford@linaro.org> > Alan Hayward <alan.hayward@arm.com> > David Sherwood <david.sherwood@arm.com> > > gcc/ > * tree-ssa-ccp.c (get_value_for_expr): Use a positive test for > INTEGER_CST rather than a negative test for ADDR_EXPR. > > Index: gcc/tree-ssa-ccp.c > =================================================================== > --- gcc/tree-ssa-ccp.c 2017-08-10 14:36:07.842479033 +0100 > +++ gcc/tree-ssa-ccp.c 2017-09-20 13:10:31.466004578 +0100 > @@ -617,7 +617,7 @@ get_value_for_expr (tree expr, bool for_ > } > } > 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;
Index: gcc/tree-ssa-ccp.c =================================================================== --- gcc/tree-ssa-ccp.c 2017-08-10 14:36:07.842479033 +0100 +++ gcc/tree-ssa-ccp.c 2017-09-20 13:10:31.466004578 +0100 @@ -617,7 +617,7 @@ get_value_for_expr (tree expr, bool for_ } } 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;