This is an archive of the discontinued LLVM Phabricator instance.

[LV] Use vector vphis for more induction variables
ClosedPublic

Authored by mkuper on Jun 2 2016, 2:41 PM.

Details

Summary

Use a real vector IV for integer IVs that are the same type as the primary, and have a constant step - but are not necessarily the primary IV itself.

This is an expansion of http://reviews.llvm.org/rL271410

Diff Detail

Repository
rL LLVM

Event Timeline

mkuper updated this revision to Diff 59460.Jun 2 2016, 2:41 PM
mkuper retitled this revision from to [LV] Use vector vphis for more induction variables.
mkuper updated this object.
mkuper added reviewers: delena, wmi.
mkuper added subscribers: llvm-commits, Ayal, nadav, davidxl.
delena added inline comments.Jun 7 2016, 5:11 AM
lib/Transforms/Vectorize/LoopVectorize.cpp
4102 ↗(On Diff #59460)

If you need only SEXT or TRUNC for a secondary induction variable, you can send the type to widenInductionVariable() in the last parameter.

mkuper added inline comments.Jun 7 2016, 1:00 PM
lib/Transforms/Vectorize/LoopVectorize.cpp
4102 ↗(On Diff #59460)

I'm intentionally getting this in in very small steps, so as not to regress the world in case the vector IVs aren't handled well by downstream passes.

In any case, passing the type to widenInductionVariable isn't the right thing here, since we don't need to truncate the start value. It should be enough to just remove the condition and let it fall into the widenInductionVariable case. That's going to be the next follow-up.

delena added inline comments.Jun 7 2016, 11:52 PM
lib/Transforms/Vectorize/LoopVectorize.cpp
2122 ↗(On Diff #59460)

I thought, that you can put here Builder.CreateSExtOrTrunc(Start, TruncType) , Start and Step should have the same type anyway.
You can change name from TruncType to CastType.

But if I'm wrong, you can submit this patch as is.

Thanks, Elena!
I'll commit this as is, and remove the restriction on types in a separate commit.

lib/Transforms/Vectorize/LoopVectorize.cpp
2122 ↗(On Diff #59460)

There are two places that call widenInductionVariable.
The callsite that calls it with a TruncType will always need a trunc, not a sext, since having a sext there make the transformation unsafe.
The callsite that calls it without a TruncType should, if I'm not mistaken, keep calling it without a TruncType - the type already matches what we want.

So, I'd rather keep it as Instruction::Trunc. SExtOrTrunc will work, but this makes what we want explicit.

This revision was automatically updated to reflect the committed changes.