aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2022-09-03 13:12:15 +0100
committerSimon Pilgrim <llvm-dev@redking.me.uk>2022-09-03 13:12:22 +0100
commite2d140e9c33739032db40b18a019ece4fb3f687a (patch)
tree3b0b20c211e5f2e7334fe3c1e9bcdbec3930f526 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent30dadaa2eb499395f5bef44b9e1a18db6360ad1f (diff)
downloadllvm-e2d140e9c33739032db40b18a019ece4fb3f687a.zip
llvm-e2d140e9c33739032db40b18a019ece4fb3f687a.tar.gz
llvm-e2d140e9c33739032db40b18a019ece4fb3f687a.tar.bz2
[TTI] Add isExpensiveToSpeculativelyExecute wrapper
CGP uses a raw `getInstructionCost(I, TargetTransformInfo::TCK_SizeAndLatency) >= TCC_Expensive` check to see if its better to move an expensive instruction used in a select behind a branch instead. This is causing issues with upcoming improvements to TCK_SizeAndLatency costs on X86 as we need to use TCK_SizeAndLatency as an uop count (so its compatible with various target-specific buffer sizes - see D132288), but we can have instructions that have a low TCK_SizeAndLatency value but should still be treated as 'expensive' (FDIV for example) - by adding a isExpensiveToSpeculativelyExecute wrapper we can keep the current behaviour but still add an x86 override in a future patch when the cost tables are updated to compensate.
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 6786e90..cd6ee4e 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -6604,8 +6604,7 @@ static bool sinkSelectOperand(const TargetTransformInfo *TTI, Value *V) {
// If it's safe to speculatively execute, then it should not have side
// effects; therefore, it's safe to sink and possibly *not* execute.
return I && I->hasOneUse() && isSafeToSpeculativelyExecute(I) &&
- TTI->getInstructionCost(I, TargetTransformInfo::TCK_SizeAndLatency) >=
- TargetTransformInfo::TCC_Expensive;
+ TTI->isExpensiveToSpeculativelyExecute(I);
}
/// Returns true if a SelectInst should be turned into an explicit branch.