re PR tree-optimization/79972 (ICE in tree check: expected ssa_name, have var_decl...
authorJakub Jelinek <jakub@redhat.com>
Fri, 10 Mar 2017 07:55:00 +0000 (08:55 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 10 Mar 2017 07:55:00 +0000 (08:55 +0100)
PR tree-optimization/79972
* gimple-ssa-warn-alloca.c (alloca_call_type): Only call
get_range_info on SSA_NAMEs.  Formatting fixes.

* gcc.dg/pr79972.c: New test.

From-SVN: r246022

gcc/ChangeLog
gcc/gimple-ssa-warn-alloca.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr79972.c [new file with mode: 0644]

index 211e9e77e124a956df6cf0d17cd1ba9612ba3eee..9a4844e2aac0fa6d060b843a44933478d1499292 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/79972
+       * gimple-ssa-warn-alloca.c (alloca_call_type): Only call
+       get_range_info on SSA_NAMEs.  Formatting fixes.
+
 2017-03-10  Richard Biener  <rguenther@suse.de>
            Jakub Jelinek  <jakub@redhat.com>
 
index dd41775f712320806cc604762efe19adb59660fd..b940efa910cdda41ee6806b9d7d4701e8f01ffdc 100644 (file)
@@ -300,8 +300,9 @@ alloca_call_type (gimple *stmt, bool is_vla, tree *invalid_casted_type)
       ret = alloca_type_and_limit (ALLOCA_OK);
     }
   // Check the range info if available.
-  else if (value_range_type range_type = get_range_info (len, &min, &max))
+  else if (TREE_CODE (len) == SSA_NAME)
     {
+      value_range_type range_type = get_range_info (len, &min, &max);
       if (range_type == VR_RANGE)
        {
          if (wi::leu_p (max, max_size))
@@ -328,7 +329,6 @@ alloca_call_type (gimple *stmt, bool is_vla, tree *invalid_casted_type)
              gimple *def = SSA_NAME_DEF_STMT (len);
              if (gimple_assign_cast_p (def)
                  && TYPE_UNSIGNED (TREE_TYPE (gimple_assign_rhs1 (def))))
-
                {
                  len_casted = gimple_assign_rhs1 (def);
                  range_type = get_range_info (len_casted, &min, &max);
@@ -344,8 +344,7 @@ alloca_call_type (gimple *stmt, bool is_vla, tree *invalid_casted_type)
              else if (range_type == VR_ANTI_RANGE)
                return alloca_type_and_limit (ALLOCA_UNBOUNDED);
              else if (range_type != VR_VARYING)
-               return
-                 alloca_type_and_limit (ALLOCA_BOUND_MAYBE_LARGE, max);
+               return alloca_type_and_limit (ALLOCA_BOUND_MAYBE_LARGE, max);
            }
        }
       else if (range_type == VR_ANTI_RANGE)
index d00f5df7540e4972efea34a9f6a8ec3394243263..b60d750a062ffdffeb91c04ad2b7bd274b45d144 100644 (file)
@@ -1,5 +1,8 @@
 2017-03-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/79972
+       * gcc.dg/pr79972.c: New test.
+
        PR tree-optimization/77975
        * gcc.dg/pr77975.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr79972.c b/gcc/testsuite/gcc.dg/pr79972.c
new file mode 100644 (file)
index 0000000..1d2b8be
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR tree-optimization/79972 */
+/* { dg-do compile } */
+/* { dg-require-effective-target alloca } */
+/* { dg-options "-Walloca -Wvla-larger-than=10000" } */
+
+int
+f (int dim, int *b, int *c)
+{
+  int newcentroid[3][dim];     /* { dg-warning "unbounded use of variable-length array" } */
+  int *a = newcentroid[2];
+  int i, dist = 0;
+  __builtin_memcpy (newcentroid, c, sizeof (newcentroid));
+  for (i = 0; i < dim; i++)
+    dist += (a[i] - b[i]) * (a[i] - b[i]);
+  return dist;
+}