Skip to content

Commit

Permalink
[AMDGPU] Incorporate feedback
Browse files Browse the repository at this point in the history
Change-Id: I12e23d6a9506a6ce6e87fdf2292b4d4f2d88c258
  • Loading branch information
chinmaydd committed Jan 6, 2025
1 parent 3d97f5c commit f0ede10
Show file tree
Hide file tree
Showing 3 changed files with 454 additions and 194 deletions.
16 changes: 7 additions & 9 deletions llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5735,22 +5735,24 @@ bool SITargetLowering::isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
// specific details.
bool SITargetLowering::isFMAFasterThanFMulAndFAdd(const Function &F,
Type *Ty) const {
SIModeRegisterDefaults Mode = SIModeRegisterDefaults(F, *Subtarget);
switch (Ty->getScalarSizeInBits()) {
case 32: {
if (!Subtarget->hasMadMacF32Insts())
return Subtarget->hasFastFMAF32();

SIModeRegisterDefaults Mode = SIModeRegisterDefaults(F, *Subtarget);
if (Mode.FP32Denormals != DenormalMode::getPreserveSign())
return Subtarget->hasFastFMAF32() || Subtarget->hasDLInsts();

return Subtarget->hasFastFMAF32() && Subtarget->hasDLInsts();
}
case 64:
return true;
case 16:
case 16: {
SIModeRegisterDefaults Mode = SIModeRegisterDefaults(F, *Subtarget);
return Subtarget->has16BitInsts() &&
Mode.FP64FP16Denormals != DenormalMode::getPreserveSign();
}
default:
break;
}
Expand Down Expand Up @@ -16973,8 +16975,6 @@ bool SITargetLowering::checkForPhysRegDependency(
}

/// 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 SITargetLowering::isProfitableToHoist(Instruction *I) const {
if (!I->hasOneUse())
return true;
Expand All @@ -16989,13 +16989,11 @@ bool SITargetLowering::isProfitableToHoist(Instruction *I) const {

const TargetOptions &Options = getTargetMachine().Options;
const Function *F = I->getFunction();
const DataLayout &DL = F->getDataLayout();
Type *Ty = User->getOperand(0)->getType();

return !isOperationLegalOrCustom(ISD::FMA, getValueType(DL, Ty)) ||
(Options.AllowFPOpFusion != FPOpFusion::Fast &&
return ((!I->hasAllowContract() || !User->hasAllowContract()) &&
Options.AllowFPOpFusion != FPOpFusion::Fast &&
!Options.UnsafeFPMath) ||
!isFMAFasterThanFMulAndFAdd(*F, Ty);
!isFMAFasterThanFMulAndFAdd(*F, User->getType());
}
default:
return true;
Expand Down
185 changes: 0 additions & 185 deletions llvm/test/CodeGen/AMDGPU/is-profitable-to-hoist-ir.ll

This file was deleted.

Loading

0 comments on commit f0ede10

Please sign in to comment.