[PATCH] D136692: [FuncSpec] Do not overestimate the specialization bonus for users inside loops.
Alexandros Lamprineas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 27 07:40:09 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdbeaf6baa2ad: [FuncSpec] Do not overestimate the specialization bonus for users inside loops. (authored by labrinea).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136692/new/
https://reviews.llvm.org/D136692
Files:
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
llvm/test/Transforms/FunctionSpecialization/function-specialization-loop.ll
Index: llvm/test/Transforms/FunctionSpecialization/function-specialization-loop.ll
===================================================================
--- llvm/test/Transforms/FunctionSpecialization/function-specialization-loop.ll
+++ llvm/test/Transforms/FunctionSpecialization/function-specialization-loop.ll
@@ -1,4 +1,4 @@
-; RUN: opt -function-specialization -func-specialization-avg-iters-cost=3 -func-specialization-size-threshold=10 -S < %s | FileCheck %s
+; RUN: opt -function-specialization -func-specialization-avg-iters-cost=5 -func-specialization-size-threshold=10 -S < %s | FileCheck %s
; Check that the loop depth results in a larger specialization bonus.
; CHECK: @foo.1(
@@ -60,4 +60,4 @@
return:
%retval.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ]
ret i32 %retval.0
-}
\ No newline at end of file
+}
Index: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -574,15 +574,16 @@
InstructionCost Cost =
TTI.getInstructionCost(U, TargetTransformInfo::TCK_SizeAndLatency);
+ // Increase the cost if it is inside the loop.
+ unsigned LoopDepth = LI.getLoopDepth(I->getParent());
+ Cost *= std::pow((double)AvgLoopIterationCount, LoopDepth);
+
// Traverse recursively if there are more uses.
// TODO: Any other instructions to be added here?
if (I->mayReadFromMemory() || I->isCast())
for (auto *User : I->users())
Cost += getUserBonus(User, TTI, LI);
- // Increase the cost if it is inside the loop.
- auto LoopDepth = LI.getLoopDepth(I->getParent());
- Cost *= std::pow((double)AvgLoopIterationCount, LoopDepth);
return Cost;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136692.471165.patch
Type: text/x-patch
Size: 1820 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221027/6167fca1/attachment.bin>
More information about the llvm-commits
mailing list