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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |easyhack
             Status|UNCONFIRMED                 |NEW
            Summary|Missed vector optimization: |Missed vector optimization:
                   |(a - b) != 0 is not         |(a - b) != 0 is not
                   |simplified to a != b for    |simplified to a != b with
                   |unsigned vectors            |an extra cast involved
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-10-07

--- Comment #2 from Drea Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> we have this simplification for scalars

The issue is not related to `a - b != 0` as we do that for vectors already.
The problem is the cast.

That is:
```
    typedef unsigned int v1u __attribute__((vector_size(sizeof(int))));
    typedef int v1i __attribute__((vector_size(sizeof(int))));
    __attribute__((noipa)) v1i
    f2 (v1u a)
    {
      v1i d = (v1i)a;
      return d != (v1i) { 0  };
    }
```

Does not remove the VCE here.
as shown by forwprop1 IR:
```
  d_3 = VIEW_CONVERT_EXPR<v1i>(a_2(D));
  _1 = d_3 != { 0 };
  _4 = VEC_COND_EXPR <_1, { -1 }, { 0 }>;
```

A simple:
(simplify
 (eqne (nop_convert @0) VECTOR_CST@1)
pattern should be able to allow this one to be optimized.

Reply via email to