[llvm] 4dd3327 - Fix return status of LoopDistribute
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 18 11:13:31 PDT 2020
Author: serge-sans-paille
Date: 2020-06-18T20:13:18+02:00
New Revision: 4dd332723de9c77e313e6aa066639716ca3c7535
URL: https://github.com/llvm/llvm-project/commit/4dd332723de9c77e313e6aa066639716ca3c7535
DIFF: https://github.com/llvm/llvm-project/commit/4dd332723de9c77e313e6aa066639716ca3c7535.diff
LOG: Fix return status of LoopDistribute
Move code that may update the IR after precondition, so that if precondition
fail, the IR isn't modified.
Differential Revision: https://reviews.llvm.org/D81225
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopDistribute.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
index 8f6c1d90655d..7867a5468891 100644
--- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
@@ -789,12 +789,6 @@ class LoopDistributeForLoop {
// instructions to partitions.
Partitions.setupPartitionIdOnInstructions();
- // To keep things simple have an empty preheader before we version or clone
- // the loop. (Also split if this has no predecessor, i.e. entry, because we
- // rely on PH having a predecessor.)
- if (!PH->getSinglePredecessor() || &*PH->begin() != PH->getTerminator())
- SplitBlock(PH, PH->getTerminator(), DT, LI);
-
// If we need run-time checks, version the loop now.
auto PtrToPartition = Partitions.computePartitionSetForPointers(*LAI);
const auto *RtPtrChecking = LAI->getRuntimePointerChecking();
@@ -807,6 +801,12 @@ class LoopDistributeForLoop {
"may not insert runtime check with convergent operation");
}
+ // To keep things simple have an empty preheader before we version or clone
+ // the loop. (Also split if this has no predecessor, i.e. entry, because we
+ // rely on PH having a predecessor.)
+ if (!PH->getSinglePredecessor() || &*PH->begin() != PH->getTerminator())
+ SplitBlock(PH, PH->getTerminator(), DT, LI);
+
if (!Pred.isAlwaysTrue() || !Checks.empty()) {
assert(!LAI->hasConvergentOp() && "inserting illegal loop versioning");
More information about the llvm-commits
mailing list