]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/114799 - SLP and patterns
authorRichard Biener <rguenther@suse.de>
Tue, 23 Apr 2024 06:39:03 +0000 (08:39 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 6 May 2024 12:11:21 +0000 (14:11 +0200)
The following plugs a hole with computing whether a SLP node has any
pattern stmts which is important to know when we want to replace it
by a CTOR from external defs.

PR tree-optimization/114799
* tree-vect-slp.cc (vect_get_and_check_slp_defs): Properly
update ->any_pattern when swapping operands.

* gcc.dg/vect/bb-slp-pr114799.c: New testcase.

(cherry picked from commit 18e8e55487238237f37f621668fdee316624981a)

gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c [new file with mode: 0644]
gcc/tree-vect-slp.cc

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c
new file mode 100644 (file)
index 0000000..70572fe
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-forwprop" } */
+
+unsigned long x;
+unsigned char y;
+
+void
+foo (void)
+{
+  unsigned long tt = y;
+  tt+=255;
+  unsigned short t1 = tt;
+  t1 = 254 - t1;
+  tt += ((unsigned long)t1);
+  x = tt;
+}
index a72dd787a34e7a30993b828ecd62db5adc726db0..570edf38ca4097333a8192bc57c436655466b735 100644 (file)
@@ -774,6 +774,12 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char swap,
                         (*oprnds_info)[i+1]->def_stmts[stmt_num]);
              std::swap ((*oprnds_info)[i]->ops[stmt_num],
                         (*oprnds_info)[i+1]->ops[stmt_num]);
+             /* After swapping some operands we lost track whether an
+                operand has any pattern defs so be conservative here.  */
+             if ((*oprnds_info)[i]->any_pattern
+                 || (*oprnds_info)[i+1]->any_pattern)
+               (*oprnds_info)[i]->any_pattern
+                 = (*oprnds_info)[i+1]->any_pattern = true;
              swapped = true;
              continue;
            }