]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vect: Fix scale-only pass in vect_gather_scatter_fn_p [PR123118].
authorRobin Dapp <rdapp@qti.qualcomm.com>
Mon, 15 Dec 2025 10:20:54 +0000 (11:20 +0100)
committerRobin Dapp <rdapp@oss.qualcomm.com>
Fri, 19 Dec 2025 18:41:53 +0000 (19:41 +0100)
In the process of refactoring the gather/scatter rework this likely got
lost.  In the "third pass" we look for a configuration with a smaller
scale and a larger offset type with the same signedness.  We want to be
able to multiply the offset by the new scale but not change the offset
sign.  What we actually checked is whether a converted offset type was
supported without setting *supported_offset_vectype.

This patch removes the check for the offset type change and replaces it
with a TYPE_SIGN match.

PR tree-optimization/123118

gcc/ChangeLog:

* tree-vect-data-refs.cc (vect_gather_scatter_fn_p): Check that
the type sign is equal.

gcc/testsuite/ChangeLog:

* g++.target/riscv/rvv/autovec/pr123118.C: New test.

gcc/testsuite/g++.target/riscv/rvv/autovec/pr123118.C [new file with mode: 0644]
gcc/tree-vect-data-refs.cc

diff --git a/gcc/testsuite/g++.target/riscv/rvv/autovec/pr123118.C b/gcc/testsuite/g++.target/riscv/rvv/autovec/pr123118.C
new file mode 100644 (file)
index 0000000..8cef5a7
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=rv64gcv -mabi=lp64d" } */
+
+long long a;
+short c, d;
+extern int e[][1][1][1];
+extern bool f[][1][4][2];
+#include <vector>
+
+void
+g ()
+{
+  for (bool b;;)
+    for (signed char h (c); h < 4; h += -4487 - 119)
+      {
+       e[b][b][b][b] = std::max (std::min ((long long) 3, a), (long long) d);
+       f[0][0][h][1] = h;
+      }
+}
index b86e17d1a95c737bd12950c12b6f5f7bdbd273dd..89a9077af0d122cd963736d36c56185c7633ae46 100644 (file)
@@ -4716,13 +4716,9 @@ vect_gather_scatter_fn_p (vec_info *vinfo, bool read_p, bool masked_p,
       unsigned int precision
        = TYPE_PRECISION (TREE_TYPE (configs[i].offset_vectype));
       if (configs[i].scale < scale
-         && precision >= needed_precision
-         && (supportable_convert_operation (CONVERT_EXPR,
-                                           configs[i].offset_vectype,
-                                           offset_vectype, &tmp)
-             || (needed_precision == offset_precision
-                 && tree_nop_conversion_p (configs[i].offset_vectype,
-                                           offset_vectype))))
+         && TYPE_SIGN (configs[i].offset_vectype)
+            == TYPE_SIGN (offset_vectype)
+         && precision >= needed_precision)
        {
          *ifn_out = configs[i].ifn;
          *offset_vectype_out = configs[i].offset_vectype;