[PATCH] D24544: SpeculativeExecution: Stop using whitelist for costs
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 13 20:32:47 PDT 2016
arsenm created this revision.
arsenm added a subscriber: llvm-commits.
Herald added a subscriber: wdng.
Just let TTI's cost do this instead of arbitrarily restricting this.
https://reviews.llvm.org/D24544
Files:
lib/Transforms/Scalar/SpeculativeExecution.cpp
Index: lib/Transforms/Scalar/SpeculativeExecution.cpp
===================================================================
--- lib/Transforms/Scalar/SpeculativeExecution.cpp
+++ lib/Transforms/Scalar/SpeculativeExecution.cpp
@@ -208,52 +208,6 @@
return false;
}
-static unsigned ComputeSpeculationCost(const Instruction *I,
- const TargetTransformInfo &TTI) {
- switch (Operator::getOpcode(I)) {
- case Instruction::GetElementPtr:
- case Instruction::Add:
- case Instruction::Mul:
- case Instruction::And:
- case Instruction::Or:
- case Instruction::Select:
- case Instruction::Shl:
- case Instruction::Sub:
- case Instruction::LShr:
- case Instruction::AShr:
- case Instruction::Xor:
- case Instruction::ZExt:
- case Instruction::SExt:
- case Instruction::Call:
- case Instruction::BitCast:
- case Instruction::PtrToInt:
- case Instruction::IntToPtr:
- case Instruction::AddrSpaceCast:
- case Instruction::FPToUI:
- case Instruction::FPToSI:
- case Instruction::UIToFP:
- case Instruction::SIToFP:
- case Instruction::FPExt:
- case Instruction::FPTrunc:
- case Instruction::FAdd:
- case Instruction::FSub:
- case Instruction::FMul:
- case Instruction::FDiv:
- case Instruction::FRem:
- case Instruction::ICmp:
- case Instruction::FCmp:
- case Instruction::ExtractElement:
- case Instruction::InsertElement:
- case Instruction::ShuffleVector:
- case Instruction::ExtractValue:
- case Instruction::InsertValue:
- return TTI.getUserCost(I);
-
- default:
- return UINT_MAX; // Disallow anything not whitelisted.
- }
-}
-
bool SpeculativeExecutionPass::considerHoistingFromTo(
BasicBlock &FromBlock, BasicBlock &ToBlock) {
SmallSet<const Instruction *, 8> NotHoisted;
@@ -269,7 +223,7 @@
unsigned TotalSpeculationCost = 0;
for (auto& I : FromBlock) {
- const unsigned Cost = ComputeSpeculationCost(&I, *TTI);
+ const unsigned Cost = TII.getUserCost(I);
if (Cost != UINT_MAX && isSafeToSpeculativelyExecute(&I) &&
AllPrecedingUsesFromBlockHoisted(&I)) {
TotalSpeculationCost += Cost;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24544.71291.patch
Type: text/x-patch
Size: 2189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160914/8bd5c1ca/attachment.bin>
More information about the llvm-commits
mailing list