summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-02-19 22:42:40 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-02-19 22:42:40 +0000
commit1347623aaf25b7fe6486479353fc87bd7541a5f7 (patch)
treeb582246cc63d446a70dbc262e6c14b34d96805b2 /lib/Transforms/InstCombine/InstCombineVectorOps.cpp
parent86b115c78b6c50c7fedbeab80128b2dcbc3cfc57 (diff)
downloadllvm-1347623aaf25b7fe6486479353fc87bd7541a5f7.tar.gz
llvm-1347623aaf25b7fe6486479353fc87bd7541a5f7.tar.bz2
llvm-1347623aaf25b7fe6486479353fc87bd7541a5f7.tar.xz
PR9218: SimplifyDemandedVectorElts can return a non-null value that is not
the instruction passed in. Make sure to account for this correctly, instead of looping infinitely. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126058 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineVectorOps.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineVectorOps.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 4aa1328f13..5caa12dfdf 100644
--- a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -426,8 +426,11 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) {
unsigned VWidth = cast<VectorType>(VecOp->getType())->getNumElements();
APInt UndefElts(VWidth, 0);
APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));
- if (SimplifyDemandedVectorElts(&IE, AllOnesEltMask, UndefElts))
+ if (Value *V = SimplifyDemandedVectorElts(&IE, AllOnesEltMask, UndefElts)) {
+ if (V != &IE)
+ return ReplaceInstUsesWith(IE, V);
return &IE;
+ }
return 0;
}
@@ -451,7 +454,9 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
APInt UndefElts(VWidth, 0);
APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));
- if (SimplifyDemandedVectorElts(&SVI, AllOnesEltMask, UndefElts)) {
+ if (Value *V = SimplifyDemandedVectorElts(&SVI, AllOnesEltMask, UndefElts)) {
+ if (V != &SVI)
+ return ReplaceInstUsesWith(SVI, V);
LHS = SVI.getOperand(0);
RHS = SVI.getOperand(1);
MadeChange = true;