This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Teach SelectionDAGBuilder's getUniformBase for gather/scatter handling to accept GEPs with more than 2 operands if the middle operands are all 0s
ClosedPublic

Authored by craig.topper on Nov 10 2017, 11:00 AM.

Details

Summary

Currently we can only get a uniform base from a simple GEP with 2 operands. This causes us to miss address folding opportunities for simple global array accesses as the test case shows.

This patch adds support for larger GEPs if the other indices are 0 since those don't require any additional computations to be inserted.

We may also want to handle constant splats of zero here, but I'm leaving that for future work when I have a real world example.

Diff Detail

Event Timeline

craig.topper created this revision.Nov 10 2017, 11:00 AM
delena added inline comments.Nov 10 2017, 1:08 PM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
3874

If !GEP->hasIndices() means that the GEP has only base - it is ok for the uniform base, but this GEP is not real, I think..

Remove the hasIndices check

delena accepted this revision.Nov 10 2017, 2:20 PM
This revision is now accepted and ready to land.Nov 10 2017, 2:20 PM
This revision was automatically updated to reflect the committed changes.