Skip to content

Commit 980a7e7

Browse files
authored
[X86][AVX10] Fix assertion with strict fcmp (#139500)
Check the strict mode and return MERGE_VALUES to fix the assertion of invalid index for values defined in Res node.
1 parent 80547cd commit 980a7e7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24573,9 +24573,11 @@ SDValue X86TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
2457324573
if (CC == ISD::SETOEQ || CC == ISD::SETUNE) {
2457424574
auto NewCC = (CC == ISD::SETOEQ) ? X86::COND_E : (X86::COND_NE);
2457524575
assert(Op0.getSimpleValueType() != MVT::bf16 && "Unsupported Type");
24576-
if (Op0.getSimpleValueType() != MVT::f80)
24577-
return getSETCC(
24576+
if (Op0.getSimpleValueType() != MVT::f80) {
24577+
SDValue Res = getSETCC(
2457824578
NewCC, DAG.getNode(X86ISD::UCOMX, dl, MVT::i32, Op0, Op1), dl, DAG);
24579+
return IsStrict ? DAG.getMergeValues({Res, Chain}, dl) : Res;
24580+
}
2457924581
}
2458024582
}
2458124583
// Handle floating point.

llvm/test/CodeGen/X86/avx10_2-cmp.ll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,24 @@ if.then66: ; preds = %entry
276276
if.end70: ; preds = %entry
277277
ret i32 0
278278
}
279+
280+
define i1 @constrained_fcmp() {
281+
; X64-LABEL: constrained_fcmp:
282+
; X64: # %bb.0: # %entry
283+
; X64-NEXT: vxorpd %xmm0, %xmm0, %xmm0
284+
; X64-NEXT: vucomxsd %xmm0, %xmm0
285+
; X64-NEXT: setne %al
286+
; X64-NEXT: retq
287+
;
288+
; X86-LABEL: constrained_fcmp:
289+
; X86: # %bb.0: # %entry
290+
; X86-NEXT: vxorpd %xmm0, %xmm0, %xmm0
291+
; X86-NEXT: vucomxsd %xmm0, %xmm0
292+
; X86-NEXT: setne %al
293+
; X86-NEXT: retl
294+
entry:
295+
%0 = tail call i1 @llvm.experimental.constrained.fcmps.f64(double 0.000000e+00, double 0.000000e+00, metadata !"une", metadata !"fpexcept.strict")
296+
ret i1 %0
297+
}
298+
299+
declare i1 @llvm.experimental.constrained.fcmps.f64(double, double, metadata, metadata)

0 commit comments

Comments
 (0)