Skip to content

Commit 1024b94

Browse files
committed
Add isKnownNeverNaN test
1 parent e727de1 commit 1024b94

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5760,6 +5760,17 @@ bool SelectionDAG::isKnownNeverNaN(SDValue Op, const APInt &DemandedElts,
57605760
return false;
57615761
return true;
57625762
}
5763+
case ISD::AssertNoFPClass: {
5764+
SDValue SDNoFPClass = Op.getOperand(1);
5765+
assert(isa<ConstantSDNode>(SDNoFPClass) && "NoFPClass is not Constant");
5766+
FPClassTest NoFPClass = static_cast<FPClassTest>(
5767+
dyn_cast<ConstantSDNode>(SDNoFPClass)->getZExtValue());
5768+
if (NoFPClass & fcNan)
5769+
return true;
5770+
if (SNaN && (NoFPClass & fcSNan))
5771+
return true;
5772+
return isKnownNeverNaN(Op.getOperand(0), SNaN, Depth + 1);
5773+
}
57635774
default:
57645775
if (Opcode >= ISD::BUILTIN_OP_END || Opcode == ISD::INTRINSIC_WO_CHAIN ||
57655776
Opcode == ISD::INTRINSIC_W_CHAIN || Opcode == ISD::INTRINSIC_VOID) {
@@ -7409,7 +7420,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
74097420
case ISD::AssertNoFPClass:
74107421
assert(N1.getValueType().isFloatingPoint() &&
74117422
"AssertNoFPClass is used for a non-floating type");
7412-
return N1;
7423+
break;
74137424
case ISD::AssertSext:
74147425
case ISD::AssertZext: {
74157426
EVT EVT = cast<VTSDNode>(N2)->getVT();

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11848,6 +11848,16 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
1184811848
SDValue Res = DAG.getMergeValues(ArrayRef(ArgValues.data(), NumValues),
1184911849
SDB->getCurSDLoc());
1185011850

11851+
FPClassTest NoFPClass = Arg.getNoFPClass();
11852+
if (NoFPClass != fcNone) {
11853+
EVT I64EVT = EVT::getIntegerVT(*DAG.getContext(), 64);
11854+
SDValue SDNoFPClass =
11855+
DAG.getConstant(static_cast<uint64_t>(NoFPClass), dl, I64EVT);
11856+
SDNodeFlags ResFlags = Res->getFlags();
11857+
Res = DAG.getNode(ISD::AssertNoFPClass, dl, Res.getValueType(), Res,
11858+
SDNoFPClass, ResFlags);
11859+
}
11860+
1185111861
SDB->setValue(&Arg, Res);
1185211862
if (!TM.Options.EnableFastISel && Res.getOpcode() == ISD::BUILD_PAIR) {
1185311863
// We want to associate the argument with the frame index, among
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc --mtriple=aarch64-linux-gnu < %s | FileCheck %s
3+
4+
define nofpclass(nzero) float @f(float noundef nofpclass(nan) %a, float noundef nofpclass(nan) %b) {
5+
; CHECK-LABEL: f:
6+
; CHECK: // %bb.0: // %entry
7+
; CHECK-NEXT: fmaxnm s0, s0, s1
8+
; CHECK-NEXT: ret
9+
entry:
10+
%cond = tail call float @llvm.maximumnum.f32(float %a, float %b)
11+
ret float %cond
12+
}

0 commit comments

Comments
 (0)