public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/104265] New: Missed vectorization in 526.blender_r
@ 2022-01-28  7:05 rguenth at gcc dot gnu.org
  2022-01-28  7:07 ` [Bug tree-optimization/104265] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-28  7:05 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-30 21:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28  7:05 [Bug tree-optimization/104265] New: Missed vectorization in 526.blender_r rguenth at gcc dot gnu.org
2022-01-28  7:07 ` [Bug tree-optimization/104265] " rguenth at gcc dot gnu.org
2022-01-28  9:50 ` marxin at gcc dot gnu.org
2022-01-29  5:20 ` pinskia at gcc dot gnu.org
2022-05-02 11:17 ` rguenth at gcc dot gnu.org
2022-08-30 21:09 ` tkoenig at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).