]> gcc.gnu.org Git - gcc.git/commitdiff
tree-optimization/95268 - fix commoning of clobbers
authorRichard Biener <rguenther@suse.de>
Fri, 22 May 2020 07:03:40 +0000 (09:03 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 22 May 2020 11:08:44 +0000 (13:08 +0200)
This fixes handling of clobbers when commoning stores.

2020-05-22  Richard Biener  <rguenther@suse.de>

PR tree-optimization/95268
* tree-ssa-sink.c (sink_common_stores_to_bb): Handle clobbers
properly.

* g++.dg/torture/pr95268.C: New testcase.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr95268.C [new file with mode: 0644]
gcc/tree-ssa-sink.c

index d22e9aa250e2fb2bce680ee4f81b74ce11f63839..b0ba14b33056f4463fbadc37d9c27e7c100a700d 100644 (file)
@@ -1,3 +1,9 @@
+2020-05-22  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/95268
+       * tree-ssa-sink.c (sink_common_stores_to_bb): Handle clobbers
+       properly.
+
 2020-05-22  Jan Hubicka  <hubicka@ucw.cz>
 
        * tree-streamer.c (record_common_node): Fix hash value of pre-streamed
index 1e8ad06f78addbae558fde2e6838fe6201c72962..5a628260925c73813925a15ec30759d1e9fea7e4 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-22  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/95268
+       * g++.dg/torture/pr95268.C: New testcase.
+
 2020-05-22  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/95248
diff --git a/gcc/testsuite/g++.dg/torture/pr95268.C b/gcc/testsuite/g++.dg/torture/pr95268.C
new file mode 100644 (file)
index 0000000..8385b86
--- /dev/null
@@ -0,0 +1,46 @@
+// { dg-do compile }
+// { dg-require-effective-target lp64 }
+// { dg-additional-options "-Wno-overflow" }
+
+#include <algorithm>
+
+extern short var_0, var_2, var_3, var_9, var_11, var_13, var_14, var_19, var_22,
+    var_32, var_37, var_44, var_57, var_59, var_63, var_70;
+extern unsigned var_5;
+extern char var_6, var_12, var_18, var_38, var_39, var_43, var_55, var_64,
+    arr_35;
+extern long var_7, var_8, var_10, var_15, var_25, var_56;
+extern int var_21, var_36, var_51, var_65, var_68, arr_7;
+extern bool var_46, var_58, var_67;
+
+void test() {
+  var_12 = 0 >= 0;
+  var_13 = arr_7;
+  var_14 = (unsigned long)var_7 >> -564810131 + 564810189;
+  var_15 = var_5;
+  var_18 = -602739307623583391;
+  var_19 = -~0;
+  var_21 = var_10 >> var_8 - 17101301574577641170ULL;
+  var_22 = var_5;
+  var_25 = var_9;
+  var_32 = std::max((unsigned)var_2, var_5);
+  var_36 = 9557;
+  var_37 = 394545925;
+  var_38 = 0 >= 0;
+  var_39 = var_5;
+  var_43 = 0;
+  var_44 = arr_35;
+  var_46 = var_7;
+  for (short a = 0; a < 9; a = 021)
+    for (short b = 0; b < 024; b += 4)
+      var_51 = std::min((long long)(var_2 ?: var_9), (long long)var_9);
+  var_55 = var_0;
+  var_56 = 3896150587;
+  var_57 = var_11;
+  var_58 = var_59 = var_11;
+  var_63 = 73;
+  var_64 = 10393232284806619711ULL;
+  var_65 = var_3;
+  var_67 = var_6;
+  var_68 = var_70 = 0;
+}
index c5b535bed4d198bb72e05a01762e130a6fb79c47..b61ecf12d1fe2fb650b998ec9bfe1dede0dd2889 100644 (file)
@@ -534,7 +534,9 @@ sink_common_stores_to_bb (basic_block bb)
              /* ??? We could handle differing SSA uses in the LHS by inserting
                 PHIs for them.  */
              else if (! operand_equal_p (gimple_assign_lhs (first_store),
-                                         gimple_assign_lhs (def), 0))
+                                         gimple_assign_lhs (def), 0)
+                      || (gimple_clobber_p (first_store)
+                          && !gimple_clobber_p (def)))
                {
                  first_store = NULL;
                  break;
@@ -546,16 +548,17 @@ sink_common_stores_to_bb (basic_block bb)
 
          /* Check if we need a PHI node to merge the stored values.  */
          bool allsame = true;
-         for (unsigned i = 1; i < vdefs.length (); ++i)
-           {
-             gimple *def = SSA_NAME_DEF_STMT (vdefs[i]);
-             if (! operand_equal_p (gimple_assign_rhs1 (first_store),
-                                    gimple_assign_rhs1 (def), 0))
-               {
-                 allsame = false;
-                 break;
-               }
-           }
+         if (!gimple_clobber_p (first_store))
+           for (unsigned i = 1; i < vdefs.length (); ++i)
+             {
+               gimple *def = SSA_NAME_DEF_STMT (vdefs[i]);
+               if (! operand_equal_p (gimple_assign_rhs1 (first_store),
+                                      gimple_assign_rhs1 (def), 0))
+                 {
+                   allsame = false;
+                   break;
+                 }
+             }
 
          /* We cannot handle aggregate values if we need to merge them.  */
          tree type = TREE_TYPE (gimple_assign_lhs (first_store));
This page took 0.131389 seconds and 5 git commands to generate.