Skip to content

Commit 5bf7b74

Browse files
Your Namewzssyqa
authored andcommitted
Use getIntrinsicInstrCost for FCanonicalize
1 parent ed73405 commit 5bf7b74

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,15 +2783,18 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
27832783
// ARG0 = fcanonicalize ARG0, ARG0 // to quiet ARG0
27842784
// ARG1 = fcanonicalize ARG1, ARG1 // to quiet ARG1
27852785
// RESULT = MAXNUM_IEEE ARG0, ARG1 // or MINNUM_IEEE
2786-
// Here fcanonicalize may be FMAXNUM_IEEE or FMINNUM_IEEE varies by
2787-
// architecture.
27882786
// FIXME: In LangRef, we claimed FMAXNUM has the same behaviour of
27892787
// FMAXNUM_IEEE, while the backend hasn't migrated the code yet.
27902788
// Finally, we will remove FMAXNUM_IEEE and FMINNUM_IEEE.
2791-
// All known platforms have both FMAXNUM_IEEE and FMINNUM_IEEE, so we
2792-
// check MAX only.
2793-
if (TLI->isOperationLegalOrPromote(ISD::FMAXNUM_IEEE, LT.second))
2794-
return LT.first * 3;
2789+
int IeeeISD =
2790+
IID == Intrinsic::maximumnum ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE;
2791+
if (TLI->isOperationLegalOrPromote(IeeeISD, LT.second)) {
2792+
IntrinsicCostAttributes FCanonicalizeAttrs(Intrinsic::canonicalize,
2793+
RetTy, Tys[0]);
2794+
InstructionCost FCanonicalizeCost =
2795+
thisT()->getIntrinsicInstrCost(FCanonicalizeAttrs, CostKind);
2796+
return LT.first + FCanonicalizeCost * 2;
2797+
}
27952798
break;
27962799
}
27972800
default:

0 commit comments

Comments
 (0)