diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2014-05-14 09:05:09 +0000 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2014-05-14 09:05:09 +0000 |
commit | eb7d69d49a0f5d68e80b53f411b559d05b46c8be (patch) | |
tree | 50102301e0e2eb133d23af5d1b2d6fbdd8d1503e /lib/Transforms/InstCombine/InstructionCombining.cpp | |
parent | 8517c90a0aa4084b3e1ce0df259694bcf62767e2 (diff) | |
download | llvm-eb7d69d49a0f5d68e80b53f411b559d05b46c8be.tar.gz llvm-eb7d69d49a0f5d68e80b53f411b559d05b46c8be.tar.bz2 llvm-eb7d69d49a0f5d68e80b53f411b559d05b46c8be.tar.xz |
Fix the case when reordering shuffle and binop produces a constant.
This resolves PR19737.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208762 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstructionCombining.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index 8c0a249aee..4c36887f62 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1085,18 +1085,18 @@ Value *InstCombiner::Descale(Value *Val, APInt Scale, bool &NoSignedWrap) { /// \brief Creates node of binary operation with the same attributes as the /// specified one but with other operands. -static BinaryOperator *CreateBinOpAsGiven(BinaryOperator &Inst, Value *LHS, - Value *RHS, - InstCombiner::BuilderTy *B) { - BinaryOperator *NewBO = cast<BinaryOperator>(B->CreateBinOp(Inst.getOpcode(), - LHS, RHS)); - if (isa<OverflowingBinaryOperator>(NewBO)) { - NewBO->setHasNoSignedWrap(Inst.hasNoSignedWrap()); - NewBO->setHasNoUnsignedWrap(Inst.hasNoUnsignedWrap()); +static Value *CreateBinOpAsGiven(BinaryOperator &Inst, Value *LHS, Value *RHS, + InstCombiner::BuilderTy *B) { + Value *BORes = B->CreateBinOp(Inst.getOpcode(), LHS, RHS); + if (BinaryOperator *NewBO = dyn_cast<BinaryOperator>(BORes)) { + if (isa<OverflowingBinaryOperator>(NewBO)) { + NewBO->setHasNoSignedWrap(Inst.hasNoSignedWrap()); + NewBO->setHasNoUnsignedWrap(Inst.hasNoUnsignedWrap()); + } + if (isa<PossiblyExactOperator>(NewBO)) + NewBO->setIsExact(Inst.isExact()); } - if (isa<PossiblyExactOperator>(NewBO)) - NewBO->setIsExact(Inst.isExact()); - return NewBO; + return BORes; } /// \brief Makes transformation of binary operation specific for vector types. @@ -1122,7 +1122,7 @@ Value *InstCombiner::SimplifyVectorOp(BinaryOperator &Inst) { isa<UndefValue>(RShuf->getOperand(1)) && LShuf->getOperand(0)->getType() == RShuf->getOperand(0)->getType() && LShuf->getMask() == RShuf->getMask()) { - BinaryOperator *NewBO = CreateBinOpAsGiven(Inst, LShuf->getOperand(0), + Value *NewBO = CreateBinOpAsGiven(Inst, LShuf->getOperand(0), RShuf->getOperand(0), Builder); Value *Res = Builder->CreateShuffleVector(NewBO, UndefValue::get(NewBO->getType()), LShuf->getMask()); @@ -1168,7 +1168,7 @@ Value *InstCombiner::SimplifyVectorOp(BinaryOperator &Inst) { NewLHS = Shuffle->getOperand(0); NewRHS = C2; } - BinaryOperator *NewBO = CreateBinOpAsGiven(Inst, NewLHS, NewRHS, Builder); + Value *NewBO = CreateBinOpAsGiven(Inst, NewLHS, NewRHS, Builder); Value *Res = Builder->CreateShuffleVector(NewBO, UndefValue::get(Inst.getType()), Shuffle->getMask()); return Res; |