-
Notifications
You must be signed in to change notification settings - Fork 13.3k
SelectionDAG: Support nofpclass(nan/qnan/snan/nzero) in arguments #130051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -859,6 +859,7 @@ def SDT_assert : SDTypeProfile<1, 1, | |
[SDTCisInt<0>, SDTCisInt<1>, SDTCisSameAs<1, 0>]>; | ||
def assertsext : SDNode<"ISD::AssertSext", SDT_assert>; | ||
def assertzext : SDNode<"ISD::AssertZext", SDT_assert>; | ||
def assernofpclass : SDNode<"ISD::AssertNoFPClass", SDTFPUnaryOp>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo inherited from the other patch |
||
def assertalign : SDNode<"ISD::AssertAlign", SDT_assert>; | ||
|
||
def convergencectrl_anchor : SDNode<"ISD::CONVERGENCECTRL_ANCHOR", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5603,7 +5603,12 @@ bool SelectionDAG::isBaseWithConstantOffset(SDValue Op) const { | |
|
||
bool SelectionDAG::isKnownNeverNaN(SDValue Op, bool SNaN, unsigned Depth) const { | ||
// If we're told that NaNs won't happen, assume they won't. | ||
if (getTarget().Options.NoNaNsFPMath || Op->getFlags().hasNoNaNs()) | ||
if (getTarget().Options.NoNaNsFPMath) | ||
return true; | ||
SDNodeFlags OpFlags = Op->getFlags(); | ||
if (SNaN && OpFlags.hasNoSNaNs()) | ||
return true; | ||
Comment on lines
+5608
to
+5610
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't need to touch the flags. This code should be directly inspecting AssertNoFPClass's carried mask |
||
if (OpFlags.hasNoSNaNs() && OpFlags.hasNoQNaNs()) | ||
return true; | ||
|
||
if (Depth >= MaxRecursionDepth) | ||
|
@@ -7370,6 +7375,10 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT, | |
N2.getOpcode() == ISD::TargetConstant && "Invalid FP_ROUND!"); | ||
if (N1.getValueType() == VT) return N1; // noop conversion. | ||
break; | ||
case ISD::AssertNoFPClass: | ||
assert(N1.getValueType().isFloatingPoint() && | ||
"AssertNoFPClass is used for a non-floating type"); | ||
return N1; | ||
case ISD::AssertSext: | ||
case ISD::AssertZext: { | ||
EVT EVT = cast<VTSDNode>(N2)->getVT(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11827,10 +11827,25 @@ void SelectionDAGISel::LowerArguments(const Function &F) { | |
AssertOp = ISD::AssertSext; | ||
else if (Arg.hasAttribute(Attribute::ZExt)) | ||
AssertOp = ISD::AssertZext; | ||
|
||
ArgValues.push_back(getCopyFromParts(DAG, dl, &InVals[i], NumParts, | ||
PartVT, VT, nullptr, NewRoot, | ||
F.getCallingConv(), AssertOp)); | ||
SDValue OutVal = | ||
getCopyFromParts(DAG, dl, &InVals[i], NumParts, PartVT, VT, nullptr, | ||
NewRoot, F.getCallingConv(), AssertOp); | ||
if (Arg.hasAttribute(Attribute::NoFPClass) && | ||
OutVal.getValueType().isFloatingPoint()) { | ||
SDNodeFlags OutValFlags = OutVal->getFlags(); | ||
bool NoSNaN = ((Arg.getNoFPClass() & llvm::fcSNan) == llvm::fcSNan); | ||
Comment on lines
+11835
to
+11836
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AssertNoFPClass should have an explicit integer mask argument that directly copies the value. You shouldn't be trying to re-encode that value as fast math flags |
||
bool NoQNaN = ((Arg.getNoFPClass() & llvm::fcQNan) == llvm::fcQNan); | ||
bool NoInf = ((Arg.getNoFPClass() & llvm::fcInf) == llvm::fcInf); | ||
bool NoNegZero = | ||
((Arg.getNoFPClass() & llvm::fcInf) == llvm::fcNegZero); | ||
OutValFlags.setNoSNaNs(NoSNaN); | ||
OutValFlags.setNoQNaNs(NoQNaN); | ||
OutValFlags.setNoInfs(NoInf); | ||
OutValFlags.setNoSignedZeros(NoNegZero); | ||
Comment on lines
+11835
to
+11844
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should not be setting any fast math flags. Particularly NSZ, the meaning of the NSZ flag is not that there isn't a -0 value |
||
OutVal = | ||
DAG.getNode(ISD::AssertNoFPClass, dl, VT, OutVal, OutValFlags); | ||
} | ||
ArgValues.push_back(OutVal); | ||
} | ||
|
||
i += NumParts; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change, shouldn't touch the fast math flags