https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123382

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2026-01-03
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.

VEC_PERM_EXPR is special and needs to be treated that way.
from tree.def:
```
   When MASK is not constant:
     MASK is an integer-typed vector.  The number of MASK elements must
     be the same as the number of elements in V0 and V1.  The size of
     the inner type of the MASK and of the V0 and V1 must be the same.

   When MASK is constant:
     MASK is an integer-typed vector.

```

So:
```
diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc
index bb30c4fb35f..d5cfdba90a4 100644
--- a/gcc/tree-if-conv.cc
+++ b/gcc/tree-if-conv.cc
@@ -2252,6 +2252,11 @@ again:
       && opnum != 0)
     return;

+  /* VEC_PERM_EXPR can't be factored out for operand 2 (the mask) if both are
constants. */
+  if (arg1_op.code == VEC_PERM_EXPR && opnum == 2
+      && TREE_CODE (new_arg0) == VECTOR_CST
+      && TREE_CODE (new_arg1) == VECTOR_CST)
+    return;

   if (!types_compatible_p (TREE_TYPE (new_arg0), TREE_TYPE (new_arg1)))
     return;
```

Reply via email to