This is an archive of the discontinued LLVM Phabricator instance.

InstSimplify: A shuffle of a splat is always the splat itself
ClosedPublic

Authored by zvi on Mar 31 2017, 1:39 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon added inline comments.Mar 31 2017, 5:37 AM
lib/Analysis/InstructionSimplify.cpp
4123 ↗(On Diff #93603)

We should only perform this if the result has the same number of elements as the source - please add a type check for RetTy == Op0->getType()

zvi added inline comments.Mar 31 2017, 10:01 AM
lib/Analysis/InstructionSimplify.cpp
4123 ↗(On Diff #93603)

Good catch.

zvi updated this revision to Diff 93790.Apr 2 2017, 8:13 AM
  1. Fixes according to Simon's comments
  2. Rebase on parent
zvi marked 2 inline comments as done.Apr 2 2017, 8:14 AM
RKSimon added inline comments.Apr 2 2017, 9:22 AM
test/Transforms/InstSimplify/shufflevector.ll
60 ↗(On Diff #93790)

Add a TODO for this?

zvi updated this revision to Diff 93799.Apr 2 2017, 10:12 AM
  1. Following another enlightening comment from Simon, generalize to when the non-splat operand is not selected from.
  2. Added the symmetrical case. Not relying on canonical form has a toll of duplication - will refactor in a follow-up patch.
zvi marked an inline comment as done.Apr 2 2017, 10:29 AM
RKSimon accepted this revision.Apr 2 2017, 11:13 AM

Thanks! LGTM - with one (optional) minor.

lib/Analysis/InstructionSimplify.cpp
4087 ↗(On Diff #93799)

This part can be done as an NFC pre-commit.

This revision is now accepted and ready to land.Apr 2 2017, 11:13 AM
zvi updated this revision to Diff 93906.Apr 3 2017, 12:06 PM
zvi edited the summary of this revision. (Show Details)

Adding a negative test to cover the case for which D31426 was reverted,

This revision was automatically updated to reflect the committed changes.