re PR tree-optimization/70310 (wrong code with vector compare at -O0)
authorRichard Biener <rguenther@suse.de>
Mon, 21 Mar 2016 13:50:50 +0000 (13:50 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 21 Mar 2016 13:50:50 +0000 (13:50 +0000)
2016-03-21  Richard Biener  <rguenther@suse.de>

PR tree-optimization/70310
* tree-vect-generic.c (expand_vector_condition): Fold the built
condition.

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

From-SVN: r234369

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

index 02c2580..fc480c7 100644 (file)
@@ -1,3 +1,9 @@
+2016-03-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/70310
+       * tree-vect-generic.c (expand_vector_condition): Fold the built
+       condition.
+
 2016-03-21  Kirill Yukhin  <kirill.yukhin@intel.com>
 
        PR target/70293
index 9f4d811..7880292 100644 (file)
@@ -1,3 +1,8 @@
+2016-03-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/70310
+       * gcc.dg/torture/pr70310.c: New testcase.
+
 2016-03-21  Kirill Yukhin  <kirill.yukhin@intel.com>
 
        PR target/70293
diff --git a/gcc/testsuite/gcc.dg/torture/pr70310.c b/gcc/testsuite/gcc.dg/torture/pr70310.c
new file mode 100644 (file)
index 0000000..a962562
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+
+typedef unsigned char v32u8 __attribute__ ((vector_size (32)));
+
+unsigned __attribute__((noinline, noclone))
+foo(unsigned u)
+{
+  v32u8 v32u8_0 = (v32u8){} > (v32u8){-u};
+  return v32u8_0[31] + v32u8_0[0];
+}
+
+int
+main ()
+{
+  unsigned x = foo(0);
+  __builtin_printf ("%08x\n",x);
+  if (x != 0)
+    __builtin_abort();
+  return 0;
+}
index cb15a95..ce91270 100644 (file)
@@ -897,7 +897,7 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
        {
          tree aa1 = tree_vec_extract (gsi, comp_inner_type, a1, width, index);
          tree aa2 = tree_vec_extract (gsi, comp_inner_type, a2, width, index);
-         aa = build2 (TREE_CODE (a), cond_type, aa1, aa2);
+         aa = fold_build2 (TREE_CODE (a), cond_type, aa1, aa2);
        }
       else
        aa = tree_vec_extract (gsi, cond_type, a, width, index);