Page MenuHomePhabricator

[SVE][LoopVectorize] Verify support for vectorizing loops with invariant loads

Authored by kmclaughlin on Mar 12 2021, 7:12 AM.



D95598 added a cost model for broadcast shuffle, which should enable loops
such as the following to vectorize, where the load of b[42] is invariant
and can be done using a scalar load + splat:

for (int i=0; i<n; ++i)
  a[i] = b[i] + b[42];

This patch adds tests to verify that we can vectorize such loops.

Diff Detail

Event Timeline

kmclaughlin created this revision.Mar 12 2021, 7:12 AM
kmclaughlin requested review of this revision.Mar 12 2021, 7:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2021, 7:12 AM

Hey Kerry,

Last time @david-arm asked me to test something like this with the reverse vector:

if (cond[i])
 a[i] = b[i] + b[42];

Is it valid to do the same here?


Should we add this:

; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t

; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.$
; WARN-NOT: warning



Just in case...could any of these be CHECK-NEXT?
I believe the test gets stronger when we use CHECK-NEXT if possible.

Hi @CarolineConcatto, it sounds like a good idea to the reverse vector case, but I guess that probably depends upon your patch (D95363)?

joechrisellis accepted this revision.Mar 17 2021, 10:09 AM

Hi @kmclaughlin -- looks good to me modulo @david-arm's and @CarolineConcatto's comments. 🙂

This revision is now accepted and ready to land.Mar 17 2021, 10:09 AM
kmclaughlin marked 2 inline comments as done.
kmclaughlin edited the summary of this revision. (Show Details)
  • Added a CHECK line for warnings and another test for the following:
if (cond[i])
 a[i] = b[i] + b[42];