diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-02-19 22:42:40 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-02-19 22:42:40 +0000 |
commit | ef200db4fd1313050dca45d71469c82ba02037e0 (patch) | |
tree | f69d0db15af38b19c820cbef04107ae759d06530 /llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp | |
parent | 5b05454f248760f64b79109686c87f1c43f0d731 (diff) | |
download | bcm5719-llvm-ef200db4fd1313050dca45d71469c82ba02037e0.tar.gz bcm5719-llvm-ef200db4fd1313050dca45d71469c82ba02037e0.zip |
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.
llvm-svn: 126058
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index 4aa1328f134..5caa12dfdfa 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/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; |