This is an archive of the discontinued LLVM Phabricator instance.

[LV] Don't emit unused scalars for uniform instructions
ClosedPublic

Authored by mssimpso on Sep 6 2016, 12:47 PM.

Details

Summary

If we identify an instruction as uniform after vectorization, we know that we should only use the value corresponding to the first vector lane of each unroll iteration. However, when scalarizing such instructions, we still produce values for the other vector lanes. This patch prevents us from generating the unused scalars.

Diff Detail

Repository
rL LLVM

Event Timeline

mssimpso updated this revision to Diff 70454.Sep 6 2016, 12:47 PM
mssimpso retitled this revision from to [LV] Don't emit unused scalars for uniform instructions.
mssimpso updated this object.
mssimpso added reviewers: mkuper, wmi, anemet.
mssimpso updated this revision to Diff 71819.Sep 19 2016, 7:41 AM

Added assert in getScalarValue.

Now that we're more conservative about the values we mark uniform in collectLoopUniforms, this patch should be ready to go. I added an assert to be safe.

mkuper accepted this revision.Sep 20 2016, 3:23 PM
mkuper edited edge metadata.

Thanks, Matt.
This LGTM, except for some nits.

lib/Transforms/Vectorize/LoopVectorize.cpp
2364 ↗(On Diff #71819)

The comment is slightly incorrect now ("last" vector lane).

2379 ↗(On Diff #71819)

As long as you're touching this, maybe change the variable name? "Width" is weird.

2380 ↗(On Diff #71819)

Maybe just build a splat (one insert + shuffle) directly?
InstCombine will clean this up, but IIUC the whole point of this patch is to generate cleaner code pre-instcombine.

This revision is now accepted and ready to land.Sep 20 2016, 3:23 PM

Thanks, Michael! I'll address your comments before committing.

lib/Transforms/Vectorize/LoopVectorize.cpp
2364 ↗(On Diff #71819)

True. I'll update the comment here.

2379 ↗(On Diff #71819)

I agree. I'll change this to "Lane" like we have in other places.

2380 ↗(On Diff #71819)

Good point!

This revision was automatically updated to reflect the committed changes.
mssimpso marked 3 inline comments as done.