[TTI] Add isExpensiveToSpeculativelyExecute wrapper
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 3 Sep 2022 12:12:15 +0000 (13:12 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 3 Sep 2022 12:12:22 +0000 (13:12 +0100)
commite2d140e9c33739032db40b18a019ece4fb3f687a
tree3b0b20c211e5f2e7334fe3c1e9bcdbec3930f526
parent30dadaa2eb499395f5bef44b9e1a18db6360ad1f
[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.
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp