This is an archive of the discontinued LLVM Phabricator instance.

Process gep (select ptr1, ptr2) in SROA
ClosedPublic

Authored by rampitec on Apr 30 2020, 4:55 PM.

Diff Detail

Event Timeline

rampitec created this revision.Apr 30 2020, 4:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2020, 4:55 PM
arsenm added inline comments.May 5 2020, 12:41 PM
llvm/lib/Transforms/Scalar/SROA.cpp
3496

Needs a newline after?

llvm/test/Transforms/SROA/select-gep.ll
16

Store something for non-undef test output?

18

This increases the instruction count if the load won't be eliminated. Can you add a test with a volatile load or something else to prevent it?

rampitec updated this revision to Diff 262227.May 5 2020, 2:26 PM
rampitec marked 4 inline comments as done.

Addressed review comments.

llvm/test/Transforms/SROA/select-gep.ll
18

It may increase instruction count, but if it will remain after SROA there is a pattern in InstCombine to revert it back. That is actually the reason why D79145 was over complicated and I have switched to processing it right in SROA.

PSDB passed.

rampitec updated this revision to Diff 262726.May 7 2020, 12:15 PM

Added one more test for select gep (select gep, gep), gep (select gep, gep).

arsenm added inline comments.May 14 2020, 3:27 PM
llvm/lib/Transforms/Scalar/SROA.cpp
3493

Early exit if not select and reduce indentation

rampitec marked an inline comment as done.May 14 2020, 3:53 PM
rampitec added inline comments.
llvm/lib/Transforms/Scalar/SROA.cpp
3493

I will have to return this if anyway after D79218. There is one if for Select and one for PHI.

rampitec marked an inline comment as done.May 14 2020, 4:01 PM
rampitec added inline comments.
llvm/lib/Transforms/Scalar/SROA.cpp
3493

I will extract it into a separate function, here and in another patch.

rampitec updated this revision to Diff 264124.May 14 2020, 4:11 PM
rampitec marked an inline comment as done.

Extracted folding into a separate function.

arsenm added inline comments.May 14 2020, 5:37 PM
llvm/lib/Transforms/Scalar/SROA.cpp
3459

The inbounds vs. noninbounds paths aren't stressed in the test

rampitec updated this revision to Diff 264267.May 15 2020, 9:49 AM
rampitec marked an inline comment as done.

Added a non-inbound GEP test.

arsenm added inline comments.May 18 2020, 5:55 PM
llvm/lib/Transforms/Scalar/SROA.cpp
3455

Probably should check there are only constant indexes?

llvm/test/Transforms/SROA/select-gep.ll
7

Should have a test with non-constant GEP indices. This probably doesn't help if they aren't constants

rampitec updated this revision to Diff 264953.May 19 2020, 10:14 AM
rampitec marked 2 inline comments as done.

Added check for constant indexes and test.

Ping! @chandlerc do you mind to take a look? Thanks in advance!

arsenm accepted this revision.May 26 2020, 12:32 PM

lgtm

This revision is now accepted and ready to land.May 26 2020, 12:32 PM
This revision was automatically updated to reflect the committed changes.