re PR tree-optimization/71428 (wrong code with -Os -fno-tree-forwprop (breaks in...
authorRichard Biener <rguenther@suse.de>
Tue, 7 Jun 2016 07:31:40 +0000 (07:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 7 Jun 2016 07:31:40 +0000 (07:31 +0000)
2016-06-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71428
* tree-ssa-math-opts.c (perform_symbolic_merge): Properly distinguish
BIT_FIELD_REF op vs. load.

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

From-SVN: r237167

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr71428.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.c

index 878ee3a5f2ecbed5165295fa6547a9b071d1e245..16e41e274e1e4f90f171551bfbf066592b7d9c13 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-07  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71428
+       * tree-ssa-math-opts.c (perform_symbolic_merge): Properly distinguish
+       BIT_FIELD_REF op vs. load.
+
 2016-06-07  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/71423
index 52bb629e4e7787bd0774c40bcbab6a7c0c5ca54b..d7d651cf4d36bf9316b227f68e78eecc7636ec3d 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-07  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71428
+       * gcc.dg/torture/pr71428.c: New testcase.
+
 2016-06-07  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/71423
diff --git a/gcc/testsuite/gcc.dg/torture/pr71428.c b/gcc/testsuite/gcc.dg/torture/pr71428.c
new file mode 100644 (file)
index 0000000..b951fcd
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fno-tree-forwprop -Wno-psabi -w" } */
+
+typedef unsigned short v64u16 __attribute__ ((vector_size (64)));
+
+v64u16
+foo (v64u16 p1)
+{
+  p1[31] |= p1[1];
+  return p1;
+}
+
+int
+main ()
+{
+  v64u16 x = foo ((v64u16){ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 });
+  if (x[31] != 1)
+    __builtin_abort();
+  return 0;
+}
index 0b0c86674f4bf24f680b7fb1e55b116372cba336..513ef0b3f4eb29a35eae8a0eb14ee8f8c24fcfd9 100644 (file)
@@ -2164,10 +2164,12 @@ perform_symbolic_merge (gimple *source_stmt1, struct symbolic_number *n1,
   struct symbolic_number *n_start;
 
   tree rhs1 = gimple_assign_rhs1 (source_stmt1);
-  if (TREE_CODE (rhs1) == BIT_FIELD_REF)
+  if (TREE_CODE (rhs1) == BIT_FIELD_REF
+      && TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
     rhs1 = TREE_OPERAND (rhs1, 0);
   tree rhs2 = gimple_assign_rhs1 (source_stmt2);
-  if (TREE_CODE (rhs2) == BIT_FIELD_REF)
+  if (TREE_CODE (rhs2) == BIT_FIELD_REF
+      && TREE_CODE (TREE_OPERAND (rhs2, 0)) == SSA_NAME)
     rhs2 = TREE_OPERAND (rhs2, 0);
 
   /* Sources are different, cancel bswap if they are not memory location with