re PR tree-optimization/82285 (Optimizing error when using enumeration)
authorRichard Biener <rguenther@suse.de>
Mon, 25 Sep 2017 11:40:23 +0000 (11:40 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 25 Sep 2017 11:40:23 +0000 (11:40 +0000)
2017-09-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/82285
* tree-vect-patterns.c (vect_recog_bool_pattern): Also handle
enumeral types.

* gcc.dg/torture/pr82285.c: New testcase.

From-SVN: r253146

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr82285.c [new file with mode: 0644]
gcc/tree-vect-patterns.c

index 8b379b751cb4d3b46fb7b2520fa1b8adfdc2f472..f618113eb6f59dd96536258ce05ae92a6e3f2afa 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82285
+       * tree-vect-patterns.c (vect_recog_bool_pattern): Also handle
+       enumeral types.
+
 2017-09-25  Tom de Vries  <tom@codesourcery.com>
 
        PR target/80035
index 6a25a14582951c61fee1365bbcd87687239dd855..333e2c8f62c9bd64f5535e28acbc71a1e291b891 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82285
+       * gcc.dg/torture/pr82285.c: New testcase.
+
 2017-09-25  Justin Squirek  <squirek@adacore.com>
 
        * gnat.dg/entry_family.adb: New testcase
diff --git a/gcc/testsuite/gcc.dg/torture/pr82285.c b/gcc/testsuite/gcc.dg/torture/pr82285.c
new file mode 100644 (file)
index 0000000..6edc750
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+
+enum tst { first = 0, second = 1 };
+
+int
+main ()
+{
+  enum tst data[16];
+
+  for (unsigned i = 0; i < 16; i++)
+    data[i] = (i < 5 ? second : first);
+
+  if (data[2] != second)
+    __builtin_abort ();
+  return 0;
+}
index cdad26112e421f599819a175f55146d84afb5fda..ed0879eddf9be535ffb7eaf3a33205f62a4a1165 100644 (file)
@@ -3643,7 +3643,7 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in,
   rhs_code = gimple_assign_rhs_code (last_stmt);
   if (CONVERT_EXPR_CODE_P (rhs_code))
     {
-      if (TREE_CODE (TREE_TYPE (lhs)) != INTEGER_TYPE
+      if (! INTEGRAL_TYPE_P (TREE_TYPE (lhs))
          || TYPE_PRECISION (TREE_TYPE (lhs)) == 1)
        return NULL;
       vectype = get_vectype_for_scalar_type (TREE_TYPE (lhs));