public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/104265] New: Missed vectorization in 526.blender_r
Date: Fri, 28 Jan 2022 07:05:11 +0000	[thread overview]
Message-ID: <bug-104265-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2022-01-28  7:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28  7:05 rguenth at gcc dot gnu.org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104265-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).