[PATCH] D139876: [LoopSimplify] Restoring the normalization of br instructions.
Dmitry Bakunevich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 13:47:54 PST 2022
dbakunevich updated this revision to Diff 482257.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139876/new/
https://reviews.llvm.org/D139876
Files:
llvm/lib/Transforms/Utils/LoopSimplify.cpp
Index: llvm/lib/Transforms/Utils/LoopSimplify.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopSimplify.cpp
+++ llvm/lib/Transforms/Utils/LoopSimplify.cpp
@@ -535,6 +535,18 @@
Changed = true;
}
+ BasicBlock *TrueBB, *FalseBB;
+ using namespace PatternMatch;
+ if (match(BI, m_Br(m_Value(), TrueBB, FalseBB)) &&
+ !L->contains(TrueBB) && L->contains(FalseBB)) {
+ if (isa<BinaryOperator>(BI->getCondition())) {
+ if (dyn_cast<BinaryOperator>(BI->getCondition())->swapOperands())
+ BI->swapSuccessors();
+ } else if (isa<ICmpInst>(BI->getCondition())) {
+ dyn_cast<ICmpInst>(BI->getCondition())->swapOperands();
+ BI->swapSuccessors();
+ }
+ }
}
// Does the loop already have a preheader? If so, don't insert one.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139876.482257.patch
Type: text/x-patch
Size: 916 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221212/01ac44d1/attachment.bin>
More information about the llvm-commits
mailing list