Skip to content

Commit 9e8d11d

Browse files
authored
[X86] Check that the type is integer before calling isUnsignedIntSetCC in combineExtSetcc. (llvm#128263)
SETULT can be an unsigned less than integer compare or a unordered less than FP compare. We need to check the VT to distinguish them. Fixes on of the issues from llvm#128237.
1 parent 62c7891 commit 9e8d11d

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55368,14 +55368,15 @@ static SDValue combineExtSetcc(SDNode *N, SelectionDAG &DAG,
5536855368
if (Size > 256 && Subtarget.useAVX512Regs())
5536955369
return SDValue();
5537055370

55371+
EVT N00VT = N0.getOperand(0).getValueType();
55372+
5537155373
// Don't fold if the condition code can't be handled by PCMPEQ/PCMPGT since
5537255374
// that's the only integer compares with we have.
5537355375
ISD::CondCode CC = cast<CondCodeSDNode>(N0.getOperand(2))->get();
55374-
if (ISD::isUnsignedIntSetCC(CC))
55376+
if (N00VT.isInteger() && ISD::isUnsignedIntSetCC(CC))
5537555377
return SDValue();
5537655378

5537755379
// Only do this combine if the extension will be fully consumed by the setcc.
55378-
EVT N00VT = N0.getOperand(0).getValueType();
5537955380
EVT MatchingVecType = N00VT.changeVectorElementTypeToInteger();
5538055381
if (Size != MatchingVecType.getSizeInBits())
5538155382
return SDValue();

llvm/test/CodeGen/X86/v8i1-masks.ll

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,17 @@ define void @neg_masks(ptr %a, ptr %b, ptr %c) nounwind uwtable noinline ssp {
150150
; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax
151151
; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %ecx
152152
; X86-AVX512-NEXT: vmovups (%ecx), %ymm0
153-
; X86-AVX512-NEXT: vcmpnltps (%eax), %ymm0, %k1
154-
; X86-AVX512-NEXT: vpcmpeqd %ymm0, %ymm0, %ymm0
155-
; X86-AVX512-NEXT: vmovdqa32 %ymm0, %ymm0 {%k1} {z}
156-
; X86-AVX512-NEXT: vpsrld $31, %ymm0, %ymm0
153+
; X86-AVX512-NEXT: vcmpnltps (%eax), %ymm0, %ymm0
154+
; X86-AVX512-NEXT: vpandd {{\.?LCPI[0-9]+_[0-9]+}}{1to8}, %ymm0, %ymm0
157155
; X86-AVX512-NEXT: vmovdqa %ymm0, (%eax)
158156
; X86-AVX512-NEXT: vzeroupper
159157
; X86-AVX512-NEXT: retl
160158
;
161159
; X64-AVX512-LABEL: neg_masks:
162160
; X64-AVX512: ## %bb.0:
163161
; X64-AVX512-NEXT: vmovups (%rsi), %ymm0
164-
; X64-AVX512-NEXT: vcmpnltps (%rdi), %ymm0, %k1
165-
; X64-AVX512-NEXT: vpcmpeqd %ymm0, %ymm0, %ymm0
166-
; X64-AVX512-NEXT: vmovdqa32 %ymm0, %ymm0 {%k1} {z}
167-
; X64-AVX512-NEXT: vpsrld $31, %ymm0, %ymm0
162+
; X64-AVX512-NEXT: vcmpnltps (%rdi), %ymm0, %ymm0
163+
; X64-AVX512-NEXT: vpandd {{\.?LCPI[0-9]+_[0-9]+}}(%rip){1to8}, %ymm0, %ymm0
168164
; X64-AVX512-NEXT: vmovdqa %ymm0, (%rax)
169165
; X64-AVX512-NEXT: vzeroupper
170166
; X64-AVX512-NEXT: retq

0 commit comments

Comments
 (0)