Skip to content

Commit dbb010d

Browse files
phoebewangdvbuka
authored andcommitted
[X86] Check MinMax has NaN and replace with NewX for minimumnum/maximumnum (llvm#164546)
It is incorrect to just check for NewX and return its ordered elements.
1 parent 23638db commit dbb010d

File tree

2 files changed

+392
-404
lines changed

2 files changed

+392
-404
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29516,11 +29516,8 @@ static SDValue LowerFMINIMUM_FMAXIMUM(SDValue Op, const X86Subtarget &Subtarget,
2951629516
if (IgnoreNaN || DAG.isKnownNeverNaN(IsNum ? NewY : NewX))
2951729517
return MinMax;
2951829518

29519-
if (DAG.isKnownNeverNaN(NewX))
29520-
NewX = NewY;
29521-
29522-
SDValue IsNaN =
29523-
DAG.getSetCC(DL, SetCCType, NewX, NewX, IsNum ? ISD::SETO : ISD::SETUO);
29519+
SDValue NaNSrc = IsNum ? MinMax : NewX;
29520+
SDValue IsNaN = DAG.getSetCC(DL, SetCCType, NaNSrc, NaNSrc, ISD::SETUO);
2952429521

2952529522
return DAG.getSelect(DL, VT, IsNaN, NewX, MinMax);
2952629523
}

0 commit comments

Comments
 (0)