Skip to content

Commit 62fe3dc

Browse files
committed
Fix PPC buildbot break caused by 4c4093e
This commit adds the isnan intrinsic and provides a default expansion for it in the SDAG. However, it makes the assumption that types it operates on are IEEE-compliant types. This is not always the case. An example of that is PPC "double double" which has a representation that - Does not need to conform to IEEE requirements for isnan as it is not an IEEE-compliant type - Does not have a representation that allows for straightforward reinterpreting as an integer and use of integer operations The result was that this commit broke __builtin_isnan for ppc_fp128 making many valid numeric values report a NaN. This patch simply changes the expansion to always expand to unordered comparison (regardless of whether FP exceptions are tracked). This is inline with previous semantics.
1 parent 71e7106 commit 62fe3dc

File tree

2 files changed

+13
-60
lines changed

2 files changed

+13
-60
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6976,8 +6976,9 @@ SDValue TargetLowering::expandISNAN(EVT ResultVT, SDValue Op, SDNodeFlags Flags,
69766976
assert(OperandVT.isFloatingPoint());
69776977

69786978
// If floating point exceptions are ignored, expand to unordered comparison.
6979-
if (Flags.hasNoFPExcept() &&
6980-
isOperationLegalOrCustom(ISD::SETCC, OperandVT.getScalarType()))
6979+
if ((Flags.hasNoFPExcept() &&
6980+
isOperationLegalOrCustom(ISD::SETCC, OperandVT.getScalarType())) ||
6981+
OperandVT == MVT::ppcf128)
69816982
return DAG.getSetCC(DL, ResultVT, Op, DAG.getConstantFP(0.0, DL, OperandVT),
69826983
ISD::SETUO);
69836984

llvm/test/CodeGen/PowerPC/ppc-fpclass.ll

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -37,39 +37,15 @@ entry:
3737
define i1 @isnan_ldouble(ppc_fp128 %x) nounwind {
3838
; CHECK-LABEL: isnan_ldouble:
3939
; CHECK: # %bb.0: # %entry
40-
; CHECK-NEXT: stwu 1, -32(1)
41-
; CHECK-NEXT: stfd 1, 16(1)
42-
; CHECK-NEXT: lis 3, 32752
43-
; CHECK-NEXT: lwz 4, 20(1)
44-
; CHECK-NEXT: stfd 2, 24(1)
45-
; CHECK-NEXT: lwz 5, 28(1)
46-
; CHECK-NEXT: cmplw 1, 4, 3
47-
; CHECK-NEXT: lwz 3, 24(1)
48-
; CHECK-NEXT: xoris 4, 4, 32752
49-
; CHECK-NEXT: lwz 6, 16(1)
50-
; CHECK-NEXT: clrlwi. 5, 5, 1
51-
; CHECK-NEXT: cmplwi 5, 5, 0
52-
; CHECK-NEXT: crandc 24, 1, 22
53-
; CHECK-NEXT: cmpwi 3, 0
54-
; CHECK-NEXT: crandc 20, 22, 2
55-
; CHECK-NEXT: cmpwi 6, 0
56-
; CHECK-NEXT: cmplwi 7, 4, 0
57-
; CHECK-NEXT: or 3, 3, 5
58-
; CHECK-NEXT: crandc 21, 5, 30
59-
; CHECK-NEXT: crandc 22, 30, 2
60-
; CHECK-NEXT: cmplwi 3, 0
61-
; CHECK-NEXT: cror 20, 20, 24
62-
; CHECK-NEXT: cror 21, 22, 21
63-
; CHECK-NEXT: crandc 20, 20, 2
64-
; CHECK-NEXT: crand 21, 2, 21
65-
; CHECK-NEXT: crnor 20, 21, 20
40+
; CHECK-NEXT: fcmpu 0, 1, 1
41+
; CHECK-NEXT: fcmpu 1, 2, 2
42+
; CHECK-NEXT: crandc 20, 7, 3
6643
; CHECK-NEXT: li 3, 1
44+
; CHECK-NEXT: crnor 20, 3, 20
6745
; CHECK-NEXT: bc 12, 20, .LBB2_1
68-
; CHECK-NEXT: b .LBB2_2
46+
; CHECK-NEXT: blr
6947
; CHECK-NEXT: .LBB2_1: # %entry
7048
; CHECK-NEXT: li 3, 0
71-
; CHECK-NEXT: .LBB2_2: # %entry
72-
; CHECK-NEXT: addi 1, 1, 32
7349
; CHECK-NEXT: blr
7450
entry:
7551
%0 = tail call i1 @llvm.isnan.ppcf128(ppc_fp128 %x)
@@ -132,39 +108,15 @@ entry:
132108
define i1 @isnan_ldouble_strictfp(ppc_fp128 %x) strictfp nounwind {
133109
; CHECK-LABEL: isnan_ldouble_strictfp:
134110
; CHECK: # %bb.0: # %entry
135-
; CHECK-NEXT: stwu 1, -32(1)
136-
; CHECK-NEXT: stfd 1, 16(1)
137-
; CHECK-NEXT: lis 3, 32752
138-
; CHECK-NEXT: lwz 4, 20(1)
139-
; CHECK-NEXT: stfd 2, 24(1)
140-
; CHECK-NEXT: lwz 5, 28(1)
141-
; CHECK-NEXT: cmplw 1, 4, 3
142-
; CHECK-NEXT: lwz 3, 24(1)
143-
; CHECK-NEXT: xoris 4, 4, 32752
144-
; CHECK-NEXT: lwz 6, 16(1)
145-
; CHECK-NEXT: clrlwi. 5, 5, 1
146-
; CHECK-NEXT: cmplwi 5, 5, 0
147-
; CHECK-NEXT: crandc 24, 1, 22
148-
; CHECK-NEXT: cmpwi 3, 0
149-
; CHECK-NEXT: crandc 20, 22, 2
150-
; CHECK-NEXT: cmpwi 6, 0
151-
; CHECK-NEXT: cmplwi 7, 4, 0
152-
; CHECK-NEXT: or 3, 3, 5
153-
; CHECK-NEXT: crandc 21, 5, 30
154-
; CHECK-NEXT: crandc 22, 30, 2
155-
; CHECK-NEXT: cmplwi 3, 0
156-
; CHECK-NEXT: cror 20, 20, 24
157-
; CHECK-NEXT: cror 21, 22, 21
158-
; CHECK-NEXT: crandc 20, 20, 2
159-
; CHECK-NEXT: crand 21, 2, 21
160-
; CHECK-NEXT: crnor 20, 21, 20
111+
; CHECK-NEXT: fcmpu 0, 1, 1
112+
; CHECK-NEXT: fcmpu 1, 2, 2
113+
; CHECK-NEXT: crandc 20, 7, 3
161114
; CHECK-NEXT: li 3, 1
115+
; CHECK-NEXT: crnor 20, 3, 20
162116
; CHECK-NEXT: bc 12, 20, .LBB5_1
163-
; CHECK-NEXT: b .LBB5_2
117+
; CHECK-NEXT: blr
164118
; CHECK-NEXT: .LBB5_1: # %entry
165119
; CHECK-NEXT: li 3, 0
166-
; CHECK-NEXT: .LBB5_2: # %entry
167-
; CHECK-NEXT: addi 1, 1, 32
168120
; CHECK-NEXT: blr
169121
entry:
170122
%0 = tail call i1 @llvm.isnan.ppcf128(ppc_fp128 %x)

0 commit comments

Comments
 (0)