]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/123755 - properly register loop mask for trapping call
authorRichard Biener <rguenther@suse.de>
Thu, 22 Jan 2026 10:22:15 +0000 (11:22 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 22 Jan 2026 12:01:37 +0000 (13:01 +0100)
The following makes sure to register a loop mask if we mask the loop
because the call could trap.

PR tree-optimization/123755
* tree-vect-stmts.cc (vectorizable_call): Register mask when
the call could trap.

* gcc.dg/vect/vect-pr123755.c: New testcase.

gcc/testsuite/gcc.dg/vect/vect-pr123755.c [new file with mode: 0644]
gcc/tree-vect-stmts.cc

diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr123755.c b/gcc/testsuite/gcc.dg/vect/vect-pr123755.c
new file mode 100644 (file)
index 0000000..888efb9
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+float a[4], b[4];
+
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 4; ++i)
+    b[i] = __builtin_fma (1024.0f, 1024.0f, a[i]);
+  return 0;
+}
index 83983742467c2bbbff9095e4c46859e5ac9ba14d..5fc115e1a1794c7c1cdc9f1d515ad4c03480d384 100644 (file)
@@ -3721,7 +3721,7 @@ vectorizable_call (vec_info *vinfo,
 
       if (loop_vinfo
          && LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)
-         && (reduc_idx >= 0 || mask_opno >= 0))
+         && (reduc_idx >= 0 || could_trap || mask_opno >= 0))
        {
          if (reduc_idx >= 0
              && (cond_fn == IFN_LAST