diff options
author | Matthew Devereau <matthew.devereau@arm.com> | 2024-04-29 15:17:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-29 15:17:48 +0100 |
commit | 6561fa3d02b746743139212f31f24c4a81e5138c (patch) | |
tree | e95bd86d3d3fb97add2110cf34aa760b9eb9aac1 /llvm/lib/Transforms/Utils/LoopUtils.cpp | |
parent | c4c8d08b81e622529aaf0bfc3020d2b9e87267b3 (diff) | |
download | llvm-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.cpp | 6 |
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; |