This is an archive of the discontinued LLVM Phabricator instance.

[CodeGenPrepare][X86] Teach optimizeGatherScatterInst to turn a splat pointer into GEP with scalar base and 0 index
ClosedPublic

Authored by craig.topper on Aug 21 2020, 1:49 PM.

Details

Summary

This helps SelectionDAGBuilder recognize the splat can be used as a uniform base.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 21 2020, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2020, 1:49 PM
craig.topper requested review of this revision.Aug 21 2020, 1:49 PM
spatel added inline comments.
llvm/lib/Analysis/VectorUtils.cpp
345

Inconsistent use of "llvm::" ? Not sure if there's some guideline/pref, but seems odd to see one Value use the namespace but the other does not.

llvm/lib/CodeGen/CodeGenPrepare.cpp
5412

I know we're doing this cast in the other clause too, but is there anything guarding this function from crashing with scalable vectors?
cc @ctetreau

llvm/test/CodeGen/X86/masked_gather_scatter.ll
3323

pre-commit baseline tests?

-Pre-commit tests
-Remove hopefully unnecessary llvm::
-Add early bailout and FIXME for scalable vetors.

If the address is a splat, generating a gather/scatter seems a little weird. I guess if the mask is non-trivial, there isn't any obvious way to rewrite it in target-independent IR. though.

No testcases for gather?

Add gather test cases

If the address is a splat, generating a gather/scatter seems a little weird. I guess if the mask is non-trivial, there isn't any obvious way to rewrite it in target-independent IR. though.

Do we have any constant mask test cases?

If the address is a splat, generating a gather/scatter seems a little weird. I guess if the mask is non-trivial, there isn't any obvious way to rewrite it in target-independent IR. though.

Do we have any constant mask test cases?

No, but I don't think it really matters for this transform. If the mask is constant and the pointer is a splat, we should probably replace the gather/scatter with scalar load/store and shuffle/extractelement in instcombine.

RKSimon accepted this revision.Sep 2 2020, 12:18 AM

OK that makes sense, LGTM

This revision is now accepted and ready to land.Sep 2 2020, 12:18 AM