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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <[email protected]>:

https://gcc.gnu.org/g:c5ae6aaa9e7ff78d81c5be106e2c12100d3425bc

commit r16-6566-gc5ae6aaa9e7ff78d81c5be106e2c12100d3425bc
Author: Andrew Pinski <[email protected]>
Date:   Sat Jan 3 11:32:02 2026 -0800

    vect/ifcvt: Don't factor out VEC_PERM_EXPR with constant masks [PR123382]

    VEC_PERM_EXPR is another special case expression where constants can mean
    something different from non-constant.
    So if we have:
    ```
      if (_5 != 0) goto <bb 4>; else goto <bb 5>;
      <bb 4>
      t_15 = VEC_PERM_EXPR <t_12, t_12, { 3, 3, 2, 3 }>;
      goto <bb 6>; [100.00%]
      <bb 5>
      t_14 = VEC_PERM_EXPR <t_12, t_12, { 0, 0, 2, 3 }>;
      <bb 6>
      # t_7 = PHI <t_15(4), t_14(5)>
    ```
    We can't factor out the VEC_PERM_EXPR here since the type
    of the vector constant can be different from the type of
    the other operands. This is unlike the operand is not a
    constant, the mask has to be an integral type which is
    similar to the other operands.

    Changes since v1:
     * v2: Expand comment on why we should reject this.

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/123382

    gcc/ChangeLog:

            * tree-if-conv.cc: Reject VEC_PERM_EXPR for factoring
            if it is the mask and they are constant.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/pr123382-1.c: New test.
            * gcc.dg/torture/pr123382-2.c: New test.

    Signed-off-by: Andrew Pinski <[email protected]>

Reply via email to