Skip to content

Commit f0ede10

Browse files
committed
[AMDGPU] Incorporate feedback
Change-Id: I12e23d6a9506a6ce6e87fdf2292b4d4f2d88c258
1 parent 3d97f5c commit f0ede10

File tree

3 files changed

+454
-194
lines changed

3 files changed

+454
-194
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5735,22 +5735,24 @@ bool SITargetLowering::isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
57355735
// specific details.
57365736
bool SITargetLowering::isFMAFasterThanFMulAndFAdd(const Function &F,
57375737
Type *Ty) const {
5738-
SIModeRegisterDefaults Mode = SIModeRegisterDefaults(F, *Subtarget);
57395738
switch (Ty->getScalarSizeInBits()) {
57405739
case 32: {
57415740
if (!Subtarget->hasMadMacF32Insts())
57425741
return Subtarget->hasFastFMAF32();
57435742

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

57475747
return Subtarget->hasFastFMAF32() && Subtarget->hasDLInsts();
57485748
}
57495749
case 64:
57505750
return true;
5751-
case 16:
5751+
case 16: {
5752+
SIModeRegisterDefaults Mode = SIModeRegisterDefaults(F, *Subtarget);
57525753
return Subtarget->has16BitInsts() &&
57535754
Mode.FP64FP16Denormals != DenormalMode::getPreserveSign();
5755+
}
57545756
default:
57555757
break;
57565758
}
@@ -16973,8 +16975,6 @@ bool SITargetLowering::checkForPhysRegDependency(
1697316975
}
1697416976

1697516977
/// Check if it is profitable to hoist instruction in then/else to if.
16976-
/// Not profitable if I and it's user can form a FMA instruction
16977-
/// because we prefer FMSUB/FMADD.
1697816978
bool SITargetLowering::isProfitableToHoist(Instruction *I) const {
1697916979
if (!I->hasOneUse())
1698016980
return true;
@@ -16989,13 +16989,11 @@ bool SITargetLowering::isProfitableToHoist(Instruction *I) const {
1698916989

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

16995-
return !isOperationLegalOrCustom(ISD::FMA, getValueType(DL, Ty)) ||
16996-
(Options.AllowFPOpFusion != FPOpFusion::Fast &&
16993+
return ((!I->hasAllowContract() || !User->hasAllowContract()) &&
16994+
Options.AllowFPOpFusion != FPOpFusion::Fast &&
1699716995
!Options.UnsafeFPMath) ||
16998-
!isFMAFasterThanFMulAndFAdd(*F, Ty);
16996+
!isFMAFasterThanFMulAndFAdd(*F, User->getType());
1699916997
}
1700016998
default:
1700116999
return true;

llvm/test/CodeGen/AMDGPU/is-profitable-to-hoist-ir.ll

Lines changed: 0 additions & 185 deletions
This file was deleted.

0 commit comments

Comments
 (0)