summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-10-20 16:58:27 +0000
committerSanjay Patel <spatel@rotateright.com>2018-10-20 16:58:27 +0000
commitec572ade202efb559e19a837c2b52d682e1889e6 (patch)
tree1de90f5d7cd3c850c0c78a36a18db43787e9c13c /llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
parent729c4362cfad343865ec24e9d2fd877163f83220 (diff)
downloadbcm5719-llvm-ec572ade202efb559e19a837c2b52d682e1889e6.tar.gz
bcm5719-llvm-ec572ade202efb559e19a837c2b52d682e1889e6.zip
[InstCombine] make code more flexible with lambda; NFC
I couldn't tell from svn history when these checks were added, but it pre-dates the split of instcombine into its own directory at rL92459. The motivation for changing the check is partly shown by the code in PR34724: https://bugs.llvm.org/show_bug.cgi?id=34724 There are also existing regression tests for SLPVectorizer with sequences of extract+insert that are likely assumed to become shuffles by the vectorizer cost models. llvm-svn: 344854
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index bcf2a25aefc..0c8d64bff43 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -898,9 +898,6 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) {
if (EI->getOperand(0) == VecOp && ExtractedIdx == InsertedIdx)
return replaceInstUsesWith(IE, VecOp);
- // If this insertelement isn't used by some other insertelement, turn it
- // (and any insertelements it points to), into one big shuffle.
-
// TODO: Looking at the user(s) to determine if this insert is a
// fold-to-shuffle opportunity does not match the usual instcombine
// constraints. We should decide if the transform is worthy based only
@@ -915,8 +912,17 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) {
// The rules for determining what is an acceptable target-independent
// shuffle mask are fuzzy because they evolve based on the backend's
// capabilities and real-world impact.
+ auto isShuffleRootCandidate = [](InsertElementInst &Insert) {
+ if (!Insert.hasOneUse())
+ return true;
+ auto *InsertUser = dyn_cast<InsertElementInst>(Insert.user_back());
+ if (!InsertUser)
+ return true;
+ return false;
+ };
- if (!IE.hasOneUse() || !isa<InsertElementInst>(IE.user_back())) {
+ // Try to form a shuffle from a chain of extract-insert ops.
+ if (isShuffleRootCandidate(IE)) {
SmallVector<Constant*, 16> Mask;
ShuffleOps LR = collectShuffleElements(&IE, Mask, nullptr, *this);
OpenPOWER on IntegriCloud