]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/118795 - fix can_vec_perm_const_p query in match.pd
authorRichard Biener <rguenther@suse.de>
Tue, 25 Mar 2025 12:45:36 +0000 (13:45 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 26 Mar 2025 07:12:48 +0000 (08:12 +0100)
When expanding to RTL we always use vec_perm_indices with two operands
which can make a difference with respect to supported vs. unsupported.
So the following adjusts a query in match.pd for target support which
got this "wrong" and using 1 for a equal operand permute.

PR middle-end/118795
* match.pd (vec_perm <vec_perm <a, b>> -> vec_perm <a, b>):
Use the appropriate check to see whether the original
outer permute was supported.

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

gcc/match.pd
gcc/testsuite/g++.dg/torture/pr118795.C [new file with mode: 0644]

index 98f637373242200d1ea57bd1f1ceb81d21a39c09..ba036e528370a19ebc76aaa41f28eb082bdb2515 100644 (file)
@@ -11121,7 +11121,7 @@ and,
     (with
      {
        vec_perm_indices sel0 (builder0, 2, nelts);
-       vec_perm_indices sel1 (builder1, 1, nelts);
+       vec_perm_indices sel1 (builder1, 2, nelts);
 
        for (int i = 0; i < nelts; i++)
         builder2.quick_push (sel0[sel1[i].to_constant ()]);
diff --git a/gcc/testsuite/g++.dg/torture/pr118795.C b/gcc/testsuite/g++.dg/torture/pr118795.C
new file mode 100644 (file)
index 0000000..fc40f81
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile }
+
+unsigned char *a();
+struct b {
+  void c() const;
+};
+void b::c() const {
+  unsigned char *d = a(), *e = a();
+  for (long f; f; ++f) {
+    e[0] = e[1] = e[2] = d[0];
+    e[3] = d[0];
+    d += 4;
+    e += 4;
+  }
+}