]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/119145 - avoid stray .MASK_CALL after vectorization
authorRichard Biener <rguenther@suse.de>
Fri, 7 Mar 2025 09:15:20 +0000 (10:15 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 2 Apr 2025 12:00:18 +0000 (14:00 +0200)
When we BB vectorize an if-converted loop body we make sure to not
leave around .MASK_LOAD or .MASK_STORE created by if-conversion but
we failed to check for .MASK_CALL.

PR tree-optimization/119145
* tree-vectorizer.cc (try_vectorize_loop_1): Avoid BB
vectorizing an if-converted loop body when there's a .MASK_CALL
in the loop body.

* gcc.dg/vect/pr119145.c: New testcase.

(cherry picked from commit 7950d4cceb9fc7559b1343c95fc651cefbe287a0)

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

diff --git a/gcc/testsuite/gcc.dg/vect/pr119145.c b/gcc/testsuite/gcc.dg/vect/pr119145.c
new file mode 100644 (file)
index 0000000..55a84a6
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+
+typedef short Quantum;
+Quantum ComplexImages_Bi_0, ComplexImages_Ai_0, ComplexImages_Ai_1;
+long ComplexImages_x;
+__attribute__((__simd__)) double atan2(double, double);
+typedef enum { MagickFalse } MagickBooleanType;
+
+struct {
+    MagickBooleanType matte;
+} *ComplexImages_images;
+
+typedef struct {
+    Quantum blue, opacity;
+} PixelPacket;
+
+typedef enum { MagnitudePhaseComplexOperator } ComplexOperator;
+PixelPacket ComplexImages_Ar, ComplexImages_Br;
+PixelPacket *ComplexImages_Ci;
+ComplexOperator ComplexImages_op;
+
+void ComplexImages()
+{
+  for (; ComplexImages_x; ComplexImages_x++)
+    switch (ComplexImages_op)
+      {
+      case MagnitudePhaseComplexOperator:
+        if (ComplexImages_images->matte)
+         ComplexImages_Ci->opacity
+           = atan2(ComplexImages_Ai_1, ComplexImages_Ar.opacity);
+       ComplexImages_Ci->blue
+         = 1.0 / (ComplexImages_Ai_0 * ComplexImages_Br.blue
+                  + ComplexImages_Ar.blue * ComplexImages_Bi_0);
+      }
+}
index 6062355b781d5ee8ec725022df657a8ec45c9ff3..35ee08796d4c93ae06447a1c9d44b18ed3f1fba6 100644 (file)
@@ -1103,7 +1103,9 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
              if (call && gimple_call_internal_p (call))
                {
                  internal_fn ifn = gimple_call_internal_fn (call);
-                 if (ifn == IFN_MASK_LOAD || ifn == IFN_MASK_STORE
+                 if (ifn == IFN_MASK_LOAD
+                     || ifn == IFN_MASK_STORE
+                     || ifn == IFN_MASK_CALL
                      /* Don't keep the if-converted parts when the ifn with
                         specifc type is not supported by the backend.  */
                      || (direct_internal_fn_p (ifn)