diff options
author | Sanjay Patel <spatel@rotateright.com> | 2020-01-31 09:37:47 -0500 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2020-01-31 09:54:35 -0500 |
commit | bc1148e7bcb0448d765aff9078d480ff1905ea1b (patch) | |
tree | f3a5312d097d11d114fa7154ce8b2b95e4fcb839 /llvm/lib/Transforms/Utils/LoopUtils.cpp | |
parent | 33f65f393f6652a0974582f7b13a9aa38a9929a3 (diff) | |
download | llvm-bc1148e7bcb0448d765aff9078d480ff1905ea1b.zip llvm-bc1148e7bcb0448d765aff9078d480ff1905ea1b.tar.gz llvm-bc1148e7bcb0448d765aff9078d480ff1905ea1b.tar.bz2 |
[PATCH] D73727: [SLP] drop poison-generating flags for shuffle reduction ops (PR44536)
We may calculate reassociable math ops in arbitrary order when creating a shuffle reduction,
so there's no guarantee that things like 'nsw' hold on those intermediate values. Drop all
poison-generating flags for safety.
This change is limited to shuffle reductions because I don't think we have a problem in the
general case (where we intersect flags of each scalar op that goes into a vector op), but if
there's evidence of other cases being wrong, we can extend this fix to cover those cases.
https://bugs.llvm.org/show_bug.cgi?id=44536
Differential Revision: https://reviews.llvm.org/D73727
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUtils.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index b1d0c83..472be10 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -937,6 +937,11 @@ llvm::getShuffleReduction(IRBuilder<> &Builder, Value *Src, unsigned Op, } if (!RedOps.empty()) propagateIRFlags(TmpVec, RedOps); + + // We may compute the reassociated scalar ops in a way that does not + // preserve nsw/nuw etc. Conservatively, drop those flags. + if (auto *ReductionInst = dyn_cast<Instruction>(TmpVec)) + ReductionInst->dropPoisonGeneratingFlags(); } // The result is in the first element of the vector. return Builder.CreateExtractElement(TmpVec, Builder.getInt32(0)); |