Make get_value_for_expr check for INTEGER_CSTs
authorRichard Sandiford <richard.sandiford@arm.com>
Wed, 18 Sep 2019 09:44:06 +0000 (09:44 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 18 Sep 2019 09:44:06 +0000 (09:44 +0000)
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  <richard.sandiford@arm.com>

gcc/
* tree-ssa-ccp.c (get_value_for_expr): Check whether CONSTANTs
are INTEGER_CSTs.

From-SVN: r275871

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

index 2842a7f4cfc7a07dd7aec78323bc79587aaa673d..57850818f2827ca15834b63b3132a8f209d01324 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-18  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * tree-ssa-ccp.c (get_value_for_expr): Check whether CONSTANTs
+       are INTEGER_CSTs.
+
 2019-09-18  Richard Sandiford  <richard.sandiford@arm.com>
 
        * gimplify.c (gimplify_decl_expr): Use poly_int_tree_p instead
index 5af3810e8f0df911554b3287be0b0d4511ed765c..311918bfaf7b651c525b889783a257cb1fbad74c 100644 (file)
@@ -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