[PATCH] Fix PR70396

Richard Biener rguenther@suse.de
Thu Mar 24 13:35:00 GMT 2016


I am testing the following obvious patch on x86_64-unknown-linux-gnu.

Richard.

2016-03-24  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/70396
	* tree-vect-stmts.c (vectorizable_comparison): Use
	get_vectype_for_scalar_type.

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

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	(revision 234453)
+++ gcc/tree-vect-stmts.c	(working copy)
@@ -7790,8 +7789,8 @@ vectorizable_comparison (gimple *stmt, g
   /* Invariant comparison.  */
   if (!vectype)
     {
-      vectype = build_vector_type (TREE_TYPE (rhs1), nunits);
-      if (tree_to_shwi (TYPE_SIZE_UNIT (vectype)) != current_vector_size)
+      vectype = get_vectype_for_scalar_type (TREE_TYPE (rhs1));
+      if (TYPE_VECTOR_SUBPARTS (vectype) != nunits)
 	return false;
     }
   else if (nunits != TYPE_VECTOR_SUBPARTS (vectype))
Index: gcc/testsuite/gcc.dg/torture/pr70396.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr70396.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr70396.c	(working copy)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+struct S2 {
+    signed f1 : 3;
+};
+int a[];
+int b, c;
+char d;
+void fn1() {
+    struct S2 e;
+    b / e.f1;
+    c = 2;
+    for (; c; c++) {
+	d = 0;
+	a[c] = ~e.f1 != d;
+    }
+}



More information about the Gcc-patches mailing list