diff options
author | Nadav Rotem <nrotem@apple.com> | 2012-10-31 21:40:39 +0000 |
---|---|---|
committer | Nadav Rotem <nrotem@apple.com> | 2012-10-31 21:40:39 +0000 |
commit | 4cb8cdab5e0002f4672c85afd467da8230dff476 (patch) | |
tree | 505933778adac9b18abdb383ccfaff8aa7cd35eb /llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | |
parent | 37756b0714acdd352eabcded82f90975cc345286 (diff) | |
download | bcm5719-llvm-4cb8cdab5e0002f4672c85afd467da8230dff476.tar.gz bcm5719-llvm-4cb8cdab5e0002f4672c85afd467da8230dff476.zip |
LoopVectorize: Preserve NSW, NUW and IsExact flags.
llvm-svn: 167174
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 94e56a17131..c9871e25f12 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -849,8 +849,19 @@ SingleBlockLoopVectorizer::vectorizeLoop(LoopVectorizationLegality *Legal) { BinaryOperator *BinOp = dyn_cast<BinaryOperator>(Inst); Value *A = getVectorValue(Inst->getOperand(0)); Value *B = getVectorValue(Inst->getOperand(1)); + // Use this vector value for all users of the original instruction. - WidenMap[Inst] = Builder.CreateBinOp(BinOp->getOpcode(), A, B); + Value *V = Builder.CreateBinOp(BinOp->getOpcode(), A, B); + WidenMap[Inst] = V; + + // Update the NSW, NUW and Exact flags. + BinaryOperator *VecOp = cast<BinaryOperator>(V); + if (isa<OverflowingBinaryOperator>(BinOp)) { + VecOp->setHasNoSignedWrap(BinOp->hasNoSignedWrap()); + VecOp->setHasNoUnsignedWrap(BinOp->hasNoUnsignedWrap()); + } + if (isa<PossiblyExactOperator>(VecOp)) + VecOp->setIsExact(BinOp->isExact()); break; } case Instruction::Select: { |