diff mbox series

Fix PR82285

Message ID alpine.LSU.2.20.1709251325150.26836@zhemvz.fhfr.qr
State New
Headers show
Series Fix PR82285 | expand

Commit Message

Richard Biener Sept. 25, 2017, 11:25 a.m. UTC
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

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.
diff mbox series

Patch

Index: gcc/tree-vect-patterns.c
===================================================================
--- gcc/tree-vect-patterns.c	(revision 253134)
+++ gcc/tree-vect-patterns.c	(working copy)
@@ -3643,7 +3643,7 @@  vect_recog_bool_pattern (vec<gimple *> *
   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));
Index: gcc/testsuite/gcc.dg/torture/pr82285.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr82285.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr82285.c	(working copy)
@@ -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;
+}