diff options
author | Nadav Rotem <nrotem@apple.com> | 2013-01-10 17:34:39 +0000 |
---|---|---|
committer | Nadav Rotem <nrotem@apple.com> | 2013-01-10 17:34:39 +0000 |
commit | c560bf638b74eb48347a7b945b90aa89ffcc1620 (patch) | |
tree | e660a1a83a6f37a970eeacbf1f5e241a3fdb8a18 /lib/Transforms/Vectorize/LoopVectorize.cpp | |
parent | 12da505d938ecfbc49b203e454bada99eda950e3 (diff) |
LoopVectorizer: Fix a bug in the vectorization of BinaryOperators. The BinaryOperator can be folded to an Undef, and we don't want to set NSW flags to undef vals.
PR14878
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172079 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r-- | lib/Transforms/Vectorize/LoopVectorize.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index cde4bb889e..4803a9d038 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1682,13 +1682,13 @@ InnerLoopVectorizer::vectorizeBlockInLoop(LoopVectorizationLegality *Legal, for (unsigned Part = 0; Part < UF; ++Part) { Value *V = Builder.CreateBinOp(BinOp->getOpcode(), A[Part], B[Part]); - // Update the NSW, NUW and Exact flags. - BinaryOperator *VecOp = cast<BinaryOperator>(V); - if (isa<OverflowingBinaryOperator>(BinOp)) { + // Update the NSW, NUW and Exact flags. Notice: V can be an Undef. + BinaryOperator *VecOp = dyn_cast<BinaryOperator>(V); + if (VecOp && isa<OverflowingBinaryOperator>(BinOp)) { VecOp->setHasNoSignedWrap(BinOp->hasNoSignedWrap()); VecOp->setHasNoUnsignedWrap(BinOp->hasNoUnsignedWrap()); } - if (isa<PossiblyExactOperator>(VecOp)) + if (VecOp && isa<PossiblyExactOperator>(VecOp)) VecOp->setIsExact(BinOp->isExact()); Entry[Part] = V; |