Tighten tree-ssa-ccp.c:get_value_for_expr condition
authorRichard Sandiford <richard.sandiford@linaro.org>
Thu, 21 Sep 2017 11:00:43 +0000 (11:00 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 21 Sep 2017 11:00:43 +0000 (11:00 +0000)
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  <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.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r253056

gcc/ChangeLog
gcc/tree-ssa-ccp.c

index 3861e6603e31d02f164e8bd12ae9797b91d42412..6f2f3d7a9df273982bbb9d79d6260d109d7eb3b3 100644 (file)
@@ -1,3 +1,10 @@
+2017-09-21  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
+       * 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  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index 3940d538ca77997a43e2a02b803c5c5f1ded9763..9811640c2a5fa17e032b2a7b7c02163bb947d0ed 100644 (file)
@@ -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;