This is an archive of the discontinued LLVM Phabricator instance.

Fold selects when the non-selected elements are undef from shufflevectors
AbandonedPublic

Authored by filcab on Apr 29 2014, 11:27 PM.

Details

Summary

If we have a select whose operands are two shufflevectors and we know the
non-selected elements are undef, replace the instruction with a
shufflevector from the source vectors of the shufflevectors.

Added test cases.

Diff Detail

Event Timeline

filcab updated this revision to Diff 8958.Apr 29 2014, 11:27 PM
filcab retitled this revision from to Fold selects when the non-selected elements are undef from shufflevectors.
filcab updated this object.
filcab edited the test plan for this revision. (Show Details)
filcab added reviewers: bkramer, eli.friedman.
filcab added a subscriber: Unknown Object (MLST).
bkramer added inline comments.May 2 2014, 10:20 AM
lib/Transforms/InstCombine/InstCombineSelect.cpp
739

IMO DeMorgan's law makes this kind of condition more readable

if (!VecTy || !TrueSV || !FalseSV)
743

Why is it important that SI has only one use?

756–758

Since you never use any VectorType methods you can skip the cast<>s here.

778

If it's not a ConstantInt it could also be a ConstantExpr instead of an Undef. You probably want to bail out in that case.

filcab updated this revision to Diff 9044.May 2 2014, 2:22 PM

Fixed bugs pointed by Benjamin Kramer.

filcab updated this revision to Diff 9045.May 2 2014, 2:26 PM

Remove files committed by accident.

bkramer added inline comments.May 2 2014, 2:33 PM
lib/Transforms/InstCombine/InstCombineSelect.cpp
734

Argument "SI" is now unused :)

739
s/&&/||/g
750

I'd prefer

if (!isa<UndefValue>(TrueV2) || !isa<UndefValue>(FalseV2))
test/Transforms/InstCombine/select.ll
1037

Can we have a more positive test case? The mask generation code isn't entirely trivial, would be good to have it verified by a test.

filcab planned changes to this revision.May 2 2014, 2:46 PM
filcab updated this revision to Diff 9049.May 2 2014, 4:32 PM

More fixes pointed by Benjamin Kramer.
Make the test-cases more strict w.r. to shufflevector mask.

filcab updated this revision to Diff 9050.May 2 2014, 4:34 PM

Remove unused argument

bkramer accepted this revision.May 3 2014, 3:14 AM
bkramer edited edge metadata.

This LGTM now.

This revision is now accepted and ready to land.May 3 2014, 3:14 AM
filcab abandoned this revision.May 26 2014, 7:11 PM

Per discussion on the mailing list (e. g: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140505/216033.html and following messages), I'm abandoning this revision.