diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2016-09-26 13:18:59 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2016-09-26 13:18:59 +0000 |
commit | 793c946ecbf1d833842d286534db958c843a3b2e (patch) | |
tree | f74a477b06541b8c8674f6c87011918a1e57eb2d /llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | |
parent | ac2f1933d418e7bcdb24f6a62ec29382cdcfba7e (diff) | |
download | bcm5719-llvm-793c946ecbf1d833842d286534db958c843a3b2e.tar.gz bcm5719-llvm-793c946ecbf1d833842d286534db958c843a3b2e.zip |
[InstCombine] Fixed bug introduced in r282237
The index of the new insertelement instruction was evaluated in the
wrong way, it was considered as the index of the inserted value instead
of index of the position, where the value should be inserted.
llvm-svn: 282401
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 7d89a5f8e41..3f4262fe13b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -1048,8 +1048,8 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, if (TmpV) { I->setOperand(1, TmpV); MadeChange = true; } bool NewUndefElts = false; - unsigned LHSIdx = -1u; - unsigned RHSIdx = -1u; + unsigned LHSIdx = -1u, LHSValIdx = -1u; + unsigned RHSIdx = -1u, RHSValIdx = -1u; bool LHSUniform = true; bool RHSUniform = true; for (unsigned i = 0; i < VWidth; i++) { @@ -1064,7 +1064,8 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, NewUndefElts = true; UndefElts.setBit(i); } else { - LHSIdx = LHSIdx == -1u ? MaskVal : LHSVWidth; + LHSIdx = LHSIdx == -1u ? i : LHSVWidth; + LHSValIdx = LHSValIdx == -1u ? MaskVal : LHSVWidth; LHSUniform = LHSUniform && (MaskVal == i); } } else { @@ -1072,7 +1073,8 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, NewUndefElts = true; UndefElts.setBit(i); } else { - RHSIdx = RHSIdx == -1u ? MaskVal - LHSVWidth : LHSVWidth; + RHSIdx = RHSIdx == -1u ? i : LHSVWidth; + RHSValIdx = RHSValIdx == -1u ? MaskVal - LHSVWidth : LHSVWidth; RHSUniform = RHSUniform && (MaskVal - LHSVWidth == i); } } @@ -1091,14 +1093,14 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, if (LHSIdx < LHSVWidth && RHSUniform) { if (auto *CV = dyn_cast<ConstantVector>(Shuffle->getOperand(0))) { Op = Shuffle->getOperand(1); - Value = CV->getOperand(LHSIdx); + Value = CV->getOperand(LHSValIdx); Idx = LHSIdx; } } if (RHSIdx < LHSVWidth && LHSUniform) { if (auto *CV = dyn_cast<ConstantVector>(Shuffle->getOperand(1))) { Op = Shuffle->getOperand(0); - Value = CV->getOperand(RHSIdx); + Value = CV->getOperand(RHSValIdx); Idx = RHSIdx; } } |