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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
             Target|                            |x86_64-*-*
           Priority|P3                          |P2
          Component|tree-optimization           |target
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-11-23
   Target Milestone|---                         |14.5

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I see vectorization also with -msse4.  We vectorize two lanes of MAX using

  vect__26.23_43 = MEM <const vector(2) float> [(float *)_65 + 4B];
  mask__32.25_53 = vect__26.23_43 > vect_R_max_y_lsm.24_52;
  vect__33.26_54 = .VCOND_MASK (mask__32.25_53, vect__26.23_43,
vect_R_max_y_lsm.24_52);

where the issue is that there's no optab for the native variant x86
supports and the above is not pattern-matched back by the x86 expansion
that manages to handle the scalar

  _28 = R_min_y_lsm.12_30 > _50;
  _29 = _28 ? _50 : R_min_y_lsm.12_30;

RTL expansion around this is quite tricky IIRC.

We attempt to build SLP from the 6-lane store and split that 4 + 2 where the
former fails because we have min/max mixed there, so we build from scalars
which eventually gets discarded because of cost.  The two-lane latter half
gets recognized in full and is vectorized as profitable.

I think vectorization wouldn't be an issue if we could expand

  mask__32.25_53 = vect_R_max_y_lsm.24_52 < vect__26.23_43;
  vect__33.26_54 = VEC_COND_EXPR <mask__32.25_53, vect__26.23_43,
vect_R_max_y_lsm.24_52>; 

back to a maxps, maybe we refuse because of the V2SF mode, I have not
attempted to trace RTL expansion yet, we do not arrive in
ix86_expand_sse_fp_minmax for V2SF, nor in ix86_expand_fp_vcond.
Instead we expand via

CODE_FOR_vcond_mask_v2sfv2si

and the mask operand ends up forced to a register:

(reg:V2SI 134 [ mask__32.25_53 ])

via expand_vec_cmp_expr and CODE_FOR_vec_cmpv2sfv2si - I suppose that
naturally excludes having

(gt:V2SI (reg:V2SF 111 [ vect__26.23 ])
    (reg:V2SF 115 [ vect__33.26 ]))

there to match/combine during RTL expansion.

IIRC we have some duplicates to this report but I also remember we fixed
cases of vectorizing min/max with plain SSE?

This is a target / RTL expansion issue.

Reply via email to