This is an archive of the discontinued LLVM Phabricator instance.

Optimization for Gather/Scatter with uniform base
ClosedPublic

Authored by delena on Jul 12 2015, 2:19 AM.

Details

Summary

Vector 'getelementptr' with scalar base is an opportunity for gather/scatter intrinsic to generate a better sequence.
While looking for uniform base, we want to use the scalar base pointer of GEP, if exists.

Diff Detail

Repository
rL LLVM

Event Timeline

delena updated this revision to Diff 29518.Jul 12 2015, 2:19 AM
delena retitled this revision from to Optimization for Gather/Scatter with uniform base.
delena updated this object.
delena added a reviewer: ab.
delena set the repository for this revision to rL LLVM.
delena added a subscriber: llvm-commits.

Vector 'getelementptr' with scalar base is an opportunity for gather/scatter intrinsic to generate a better sequence.
While looking for uniform base, we want to use the scalar base pointer of GEP, if exists.

ab added inline comments.Jul 15 2015, 4:12 AM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
3083 ↗(On Diff #29518)

unform -> uniform

3084 ↗(On Diff #29518)

receive -> take, perhaps?

3085 ↗(On Diff #29518)

Perhaps IR examples for both representations might be helpful?

3111–3112 ↗(On Diff #29518)

else on the same line?

3116–3117 ↗(On Diff #29518)

Should we check that the insertelement index is 0? (or even generalize and check that the broadcast and insertelement have the same index, though that sounds unnecessary)

3121 ↗(On Diff #29518)

inside -> inside the

3129 ↗(On Diff #29518)

unnecessary end-of-line whitespace?

3140 ↗(On Diff #29518)

I'm a bit uneasy with changing IndexVal outside the if(): when the latter fails, IndexVal will be incorrect for subsequent users.

Not sure it's better, but what about something like:

Value *OrigIndexVal = ...;
if (SDB->findValue(OrigIndexVal)) {
  IndexVal = OrigIndexVal;
  ...
}
3146 ↗(On Diff #29518)

Why not EVT?

delena updated this revision to Diff 29879.Jul 16 2015, 3:49 AM
delena removed rL LLVM as the repository for this revision.
delena marked 6 inline comments as done.

Ahmed,

Thanks a lot for the review. I addressed all your comments and uploaded a new patch.

delena added inline comments.Jul 23 2015, 8:31 AM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
3084 ↗(On Diff #29518)

Vector of pointers is the first argument of Gather/Scatter

3116–3117 ↗(On Diff #29518)

I submitted another patch with getSplatValue() as vector utility and planned to use it here, but it is stuck on review.
http://reviews.llvm.org/D11124

3140 ↗(On Diff #29518)

Actually, I don't need the IndexVal any more, but I changed the code.

3146 ↗(On Diff #29518)

The same interface in EVT requires Context. But I changed, the result is the same.

hfinkel accepted this revision.Jul 25 2015, 5:31 PM
hfinkel added a reviewer: hfinkel.
hfinkel added a subscriber: hfinkel.

This LGTM, but let's get getSplatValue figured out, commit that, and then commit this patch using getSplatValue.

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
3122 ↗(On Diff #29879)

I suppose you'll replace this logic with getSplatValue when that lands.

This revision is now accepted and ready to land.Jul 25 2015, 5:31 PM
delena updated this revision to Diff 33536.Aug 30 2015, 7:05 AM
delena edited edge metadata.
delena set the repository for this revision to rL LLVM.
delena added a subscriber: jmolloy.

I use the new interface getSplatValue().
I added more tests, Hal and James asked for.

This revision was automatically updated to reflect the committed changes.