Skip to content

[X86] Switch operands order for FMINIMUMNUM/FMAXIMUMNUM #147193

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

Merged
merged 1 commit into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29422,16 +29422,22 @@ static SDValue LowerFMINIMUM_FMAXIMUM(SDValue Op, const X86Subtarget &Subtarget,
Op->getFlags().hasNoNaNs() || (IsXNeverNaN && IsYNeverNaN);

// If we did no ordering operands for signed zero handling and we need
// to process NaN and we know that the second operand is not NaN then put
// it in first operand and we will not need to post handle NaN after max/min.
if (IgnoreSignedZero && !IgnoreNaN && DAG.isKnownNeverNaN(NewY))
// to process NaN and we know that one of the operands is not NaN then:
// - For minimum/maximum, put it in the first operand,
// - For minimumnum/maximumnum, put it in the second operand,
// and we will not need to post handle NaN after max/min.
if (IgnoreSignedZero && !IgnoreNaN &&
DAG.isKnownNeverNaN(IsNum ? NewX : NewY))
std::swap(NewX, NewY);

SDValue MinMax = DAG.getNode(MinMaxOp, DL, VT, NewX, NewY, Op->getFlags());

if (IgnoreNaN || DAG.isKnownNeverNaN(NewX))
if (IgnoreNaN || DAG.isKnownNeverNaN(IsNum ? NewY : NewX))
return MinMax;

if (DAG.isKnownNeverNaN(NewX))
NewX = NewY;

SDValue IsNaN =
DAG.getSetCC(DL, SetCCType, NewX, NewX, IsNum ? ISD::SETO : ISD::SETUO);

Expand Down
Loading
Loading