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

            Bug ID: 126159
           Summary: Missed vectorization for load-lanes with 2 groups
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liuhongt at gcc dot gnu.org
  Target Milestone: ---

typedef union { int i; float f; } RtreeCoord;               
#define MIN(a,b) ((a)<(b)?(a):(b))                          
#define MAX(a,b) ((a)>(b)?(a):(b))                          

void cellUnion_f(RtreeCoord *a1, RtreeCoord *a2, int n) {   
  int ii = 0;                                               
  do {                                                      
    a1[ii].f   = MIN(a1[ii].f,   a2[ii].f);                 
    a1[ii+1].f = MAX(a1[ii+1].f, a2[ii+1].f);               
    ii += 2;                                                
  } while (ii < n);                                         
}                                                           

void cellUnion_i(RtreeCoord *a1, RtreeCoord *a2, int n) {   
  int ii = 0;                                               
  do {                                                      
    a1[ii].i   = MIN(a1[ii].i,   a2[ii].i);                 
    a1[ii+1].i = MAX(a1[ii+1].i, a2[ii+1].i);               
    ii += 2;                                                
  } while (ii < n);                                         
}                                                           


GCC recognises the group but asks for an array_mode V8SF[2] (load-lanes with 2
groups); x86 has no such mode, so it gives up instead of doing a shuffle-based
even/odd de-interleave + a vector MIN and vector MAX + re-interleave (all cheap
AVX-512 ops). A genuine missed opportunity: a manual split into even/odd
MIN/MAX vectorizes fine.

Reply via email to