aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-08-11 09:25:01 +0200
committerGitHub <noreply@github.com>2025-08-11 09:25:01 +0200
commit35bad229c1bc1f27fe58f9d37f8592fc67a7112c (patch)
tree0af0d793810e5fceb29acaed5b027e0f923e4dc2 /llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
parente8918c318ee62973867e7ac3d3250a4478f2f04d (diff)
downloadllvm-35bad229c1bc1f27fe58f9d37f8592fc67a7112c.zip
llvm-35bad229c1bc1f27fe58f9d37f8592fc67a7112c.tar.gz
llvm-35bad229c1bc1f27fe58f9d37f8592fc67a7112c.tar.bz2
[PredicateInfo] Use bitcast instead of ssa.copy (#151174)
PredicateInfo needs some no-op to which the predicate can be attached. Currently this is an ssa.copy intrinsic. This PR replaces it with a no-op bitcast. Using a bitcast is more efficient because we don't have the overhead of an overloaded intrinsic. It also makes things slightly simpler overall.
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionSpecialization.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionSpecialization.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
index 45fa9d5..c876a47 100644
--- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -400,12 +400,6 @@ Constant *InstCostVisitor::visitFreezeInst(FreezeInst &I) {
Constant *InstCostVisitor::visitCallBase(CallBase &I) {
assert(LastVisited != KnownConstants.end() && "Invalid iterator!");
- // Look through calls to ssa_copy intrinsics.
- if (auto *II = dyn_cast<IntrinsicInst>(&I);
- II && II->getIntrinsicID() == Intrinsic::ssa_copy) {
- return LastVisited->second;
- }
-
Function *F = I.getCalledFunction();
if (!F || !canConstantFoldCallTo(&I, F))
return nullptr;
@@ -611,17 +605,15 @@ void FunctionSpecializer::promoteConstantStackValues(Function *F) {
}
}
-// ssa_copy intrinsics are introduced by the SCCP solver. These intrinsics
-// interfere with the promoteConstantStackValues() optimization.
+// The SCCP solver inserts bitcasts for PredicateInfo. These interfere with the
+// promoteConstantStackValues() optimization.
static void removeSSACopy(Function &F) {
for (BasicBlock &BB : F) {
for (Instruction &Inst : llvm::make_early_inc_range(BB)) {
- auto *II = dyn_cast<IntrinsicInst>(&Inst);
- if (!II)
- continue;
- if (II->getIntrinsicID() != Intrinsic::ssa_copy)
+ auto *BC = dyn_cast<BitCastInst>(&Inst);
+ if (!BC || BC->getType() != BC->getOperand(0)->getType())
continue;
- Inst.replaceAllUsesWith(II->getOperand(0));
+ Inst.replaceAllUsesWith(BC->getOperand(0));
Inst.eraseFromParent();
}
}