[llvm] a7322a2 - [LICM] Delay fetching of preheader (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 10 07:16:56 PST 2023
Author: Nikita Popov
Date: 2023-03-10T16:16:48+01:00
New Revision: a7322a2171e99fe9c465c3e13c49563b19402ae0
URL: https://github.com/llvm/llvm-project/commit/a7322a2171e99fe9c465c3e13c49563b19402ae0
DIFF: https://github.com/llvm/llvm-project/commit/a7322a2171e99fe9c465c3e13c49563b19402ae0.diff
LOG: [LICM] Delay fetching of preheader (NFC)
Only fetch preheader once we want to actually hoist. It turns out
that calculating the preheader is expensive enough to affect
overall compile-time if you do it for every single instruction.
Addresses the compile-time regression from D143726.
Added:
Modified:
llvm/lib/Transforms/Scalar/LICM.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index a79e3955ce18..b181fae22f26 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -2415,8 +2415,6 @@ bool pointerInvalidatedByBlock(BasicBlock &BB, MemorySSA &MSSA, MemoryUse &MU) {
static bool hoistMinMax(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo,
MemorySSAUpdater &MSSAU) {
- auto *Preheader = L.getLoopPreheader();
- assert(Preheader && "Loop is not in simplify form?");
bool Inverse = false;
bool IsLogical = false;
using namespace PatternMatch;
@@ -2465,6 +2463,8 @@ static bool hoistMinMax(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo,
Intrinsic::ID id = ICmpInst::isSigned(P1)
? (UseMin ? Intrinsic::smin : Intrinsic::smax)
: (UseMin ? Intrinsic::umin : Intrinsic::umax);
+ auto *Preheader = L.getLoopPreheader();
+ assert(Preheader && "Loop is not in simplify form?");
IRBuilder<> Builder(Preheader->getTerminator());
// We are about to create a new guaranteed use for RHS2 which might not exist
// before (if it was a non-taken input of logical and/or instruction). If it
More information about the llvm-commits
mailing list