aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUtils.cpp
diff options
context:
space:
mode:
authorMatthew Devereau <matthew.devereau@arm.com>2024-04-29 15:17:48 +0100
committerGitHub <noreply@github.com>2024-04-29 15:17:48 +0100
commit6561fa3d02b746743139212f31f24c4a81e5138c (patch)
treee95bd86d3d3fb97add2110cf34aa760b9eb9aac1 /llvm/lib/Transforms/Utils/LoopUtils.cpp
parentc4c8d08b81e622529aaf0bfc3020d2b9e87267b3 (diff)
downloadllvm-6561fa3d02b746743139212f31f24c4a81e5138c.zip
llvm-6561fa3d02b746743139212f31f24c4a81e5138c.tar.gz
llvm-6561fa3d02b746743139212f31f24c4a81e5138c.tar.bz2
[LoopUnswitch] Allow i1 truncs in loop unswitch (#89738)
With the addition of #84628, truncs to i1 are being emitted as conditions to branch instructions. This caused significant regressions in cases which were previously improved by loop unswitch. Adding truncs to i1 restore the previous performance seen.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 73c5d63..e3e09d1 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -1930,10 +1930,12 @@ llvm::hasPartialIVCondition(const Loop &L, unsigned MSSAThreshold,
if (!TI || !TI->isConditional())
return {};
- auto *CondI = dyn_cast<CmpInst>(TI->getCondition());
+ auto *CondI = dyn_cast<Instruction>(TI->getCondition());
// The case with the condition outside the loop should already be handled
// earlier.
- if (!CondI || !L.contains(CondI))
+ // Allow CmpInst and TruncInsts as they may be users of load instructions
+ // and have potential for partial unswitching
+ if (!CondI || !isa<CmpInst, TruncInst>(CondI) || !L.contains(CondI))
return {};
SmallVector<Instruction *> InstToDuplicate;