This is an archive of the discontinued LLVM Phabricator instance.

[LV] Refactor all runtime check emissions into helper functions.
ClosedPublic

Authored by jmolloy on Aug 30 2015, 4:07 AM.

Details

Summary

This reduces the complexity of createEmptyBlock() and will open the door to further refactoring.

The test change is simply because we're now constant folding a trivial test.

It's now very obvious that one test (emitMinimumIterationCountCheck) dominates another (emitVectorLoopEnteredCheck). I haven't removed the latter in this commit as I wanted to keep it as NFC as possible.

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 33530.Aug 30 2015, 4:07 AM
jmolloy retitled this revision from to [LV] Refactor all runtime check emissions into helper functions..
jmolloy updated this object.
jmolloy added reviewers: anemet, mzolotukhin, hfinkel.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
mzolotukhin added inline comments.Aug 30 2015, 1:54 PM
lib/Transforms/Vectorize/LoopVectorize.cpp
2694–2695

You could probably use CmpInst::Create as in the original code here, to make this path purely NFC, and then change CmpInst::Create to Builder.CreateICmpULT in a separate patch. But it's up to you - I'm ok with both options.
And again, I recommend to verify that no unwanted changed sneaked in by comparing IR of some tests (I believe Adam did something like this when he worked on LAA).

jmolloy added inline comments.Aug 31 2015, 10:11 AM
lib/Transforms/Vectorize/LoopVectorize.cpp
2694–2695

That makes sense. I've checked the IR output of all tests in the LoopVectorize/ directory and the only diffs (apart from changes in unique variable names) are to do with constant folding.

I'll commit this as two separate patches.

mzolotukhin edited edge metadata.Sep 1 2015, 11:11 AM

Hi James,

The patch LGTM, some comments inline.

lib/Transforms/Vectorize/LoopVectorize.cpp
2862

Following the logic from D12477 - should we jump to ScalarPH here too? (And in the following checks)

2885–2886

BypassBuilder is now only used in one place (where Value *CRD is built). Maybe we could define it closer to the actual use (or get rid of it entirely). If you prefer, that might be a separate patch too.
And I still suspect that we're changing existing behavior here, because we might emit "cmp.zero" check in another block, but probably it's not a big deal.

mzolotukhin accepted this revision.Sep 1 2015, 11:12 AM
mzolotukhin edited edge metadata.
This revision is now accepted and ready to land.Sep 1 2015, 11:12 AM
jmolloy closed this revision.Sep 2 2015, 4:57 AM

r246634, with the IRBuilder move in r246635.

Thanks!

lib/Transforms/Vectorize/LoopVectorize.cpp
2862

Yes; in fact D12477 does exactly that - D12477 is based upon this revision. I'd prefer to keep this revision NFC if that's alright, and keep the switch to ScalarPH in D12477.

2885–2886

I have a patch in my rebase history to do exactly that, I just didn't bother putting it up for review because it's trivial. I'll commit it with this :)