Skip to content

Commit 35cb961

Browse files
committed
!fixup, always calculate cost of vfcmp and vselect.
1 parent d5a0cec commit 35cb961

File tree

2 files changed

+159
-157
lines changed

2 files changed

+159
-157
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,13 +1506,15 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
15061506
Cost +=
15071507
getCastInstrCost(IsSigned ? Instruction::FPToSI : Instruction::FPToUI,
15081508
RetTy, SrcTy, TTI::CastContextHint::None, CostKind);
1509-
if (IsSigned) {
1510-
Type *CondTy = RetTy->getWithNewBitWidth(1);
1511-
Cost += getCmpSelInstrCost(BinaryOperator::FCmp, SrcTy, CondTy,
1512-
CmpInst::FCMP_UNO, CostKind);
1513-
Cost += getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
1514-
CmpInst::FCMP_UNO, CostKind);
1515-
}
1509+
1510+
// Handle NaN.
1511+
// vmfne v0, v8, v8 # If v8[i] is NaN set v0[i] to 1.
1512+
// vmerge.vim v8, v8, 0, v0 # Convert NaN to 0.
1513+
Type *CondTy = RetTy->getWithNewBitWidth(1);
1514+
Cost += getCmpSelInstrCost(BinaryOperator::FCmp, SrcTy, CondTy,
1515+
CmpInst::FCMP_UNO, CostKind);
1516+
Cost += getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
1517+
CmpInst::FCMP_UNO, CostKind);
15161518
return Cost;
15171519
}
15181520
}

0 commit comments

Comments
 (0)