https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104265
Bug ID: 104265
Summary: Missed vectorization in 526.blender_r
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
Target Milestone: ---
Blenders hottest spot is rayobject_bb_intersect_test which can be summarized as
struct Isect {
float start[3];
float dir[3];
float dist;
float origstart[3];
float origdir[3];
int bv_index[6];
float idot_axis[3];
/* More stuff. */
void *userdata; /* aligns it to 8 */
};
int rayobject_bb_intersect_test (struct Isect *isec, const float *bb)
{
float t1x = (bb[isec->bv_index[0]] - isec->start[0]) * isec->idot_axis[0];
float t2x = (bb[isec->bv_index[1]] - isec->start[0]) * isec->idot_axis[0];
float t1y = (bb[isec->bv_index[2]] - isec->start[1]) * isec->idot_axis[1];
float t2y = (bb[isec->bv_index[3]] - isec->start[1]) * isec->idot_axis[1];
float t1z = (bb[isec->bv_index[4]] - isec->start[2]) * isec->idot_axis[2];
float t2z = (bb[isec->bv_index[5]] - isec->start[2]) * isec->idot_axis[2];
if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y <
t1z) return 0;
if (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return 0;
if (t1x > isec->dist || t1y > isec->dist || t1z > isec->dist) return 0;
return 1;
}
at least on x86 with SSE4 (for some extra permutes) we can vectorize the
comparisons, carefully filling extra lanes of V4SF vectors with redundant
data from another lane starting with {t1x,t1y,t1z,} {t2x,t2y,t2z,}
vectors. AOCC does this kind of vectorization and receives a nice 25%
uplift in performance from it.