[llvm] [llvm][AMDGPU] Implemented isProfitableToHoist and isFMAFasterThanFMulAndFAdd (PR #108756)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 15 07:15:01 PDT 2024
================
@@ -1000,6 +1031,33 @@ bool AMDGPUTargetLowering::isTruncateFree(Type *Source, Type *Dest) const {
return DestSize < SrcSize && DestSize % 32 == 0;
}
+/// Check if it is profitable to hoist instruction in then/else to if.
+/// Not profitable if I and it's user can form a FMA instruction
+/// because we prefer FMSUB/FMADD.
+bool AMDGPUTargetLowering::isProfitableToHoist(Instruction *I) const {
+ if (I->getOpcode() != Instruction::FMul)
+ return true;
+
+ if (!I->hasOneUse())
+ return true;
+
+ Instruction *User = I->user_back();
+
+ if (!(User->getOpcode() == Instruction::FSub ||
----------------
arsenm wrote:
Push negate through parentheses
https://github.com/llvm/llvm-project/pull/108756
More information about the llvm-commits
mailing list