[DAGCombine] foldVSelectOfConstants - ensure constants are same type
Fix bug identified by https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21167, foldVSelectOfConstants must ensure that the 2 build vectors have scalars of the same type before trying to compare APInt values.
This commit is contained in:
parent
6174fddbe3
commit
2a2d242017
@ -8975,6 +8975,8 @@ SDValue DAGCombiner::foldVSelectOfConstants(SDNode *N) {
|
||||
SDValue N2Elt = N2.getOperand(i);
|
||||
if (N1Elt.isUndef() || N2Elt.isUndef())
|
||||
continue;
|
||||
if (N1Elt.getValueType() != N2Elt.getValueType())
|
||||
continue;
|
||||
|
||||
const APInt &C1 = cast<ConstantSDNode>(N1Elt)->getAPIntValue();
|
||||
const APInt &C2 = cast<ConstantSDNode>(N2Elt)->getAPIntValue();
|
||||
|
||||
@ -256,3 +256,42 @@ define <4 x i32> @cmp_sel_0_or_1_vec(<4 x i32> %x, <4 x i32> %y) {
|
||||
ret <4 x i32> %add
|
||||
}
|
||||
|
||||
; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21167
|
||||
define <2 x i37> @ossfuzz21167(<2 x i37> %x, <2 x i37> %y) {
|
||||
; SSE-LABEL: ossfuzz21167:
|
||||
; SSE: # %bb.0: # %BB
|
||||
; SSE-NEXT: psllq $27, %xmm1
|
||||
; SSE-NEXT: movdqa %xmm1, %xmm0
|
||||
; SSE-NEXT: psrad $27, %xmm0
|
||||
; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,3,2,3]
|
||||
; SSE-NEXT: psrlq $27, %xmm1
|
||||
; SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
|
||||
; SSE-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
|
||||
; SSE-NEXT: movdqa {{.*#+}} xmm0 = [2147483648,2147483648]
|
||||
; SSE-NEXT: pxor %xmm0, %xmm1
|
||||
; SSE-NEXT: movdqa %xmm1, %xmm2
|
||||
; SSE-NEXT: pcmpgtd %xmm0, %xmm2
|
||||
; SSE-NEXT: pcmpeqd %xmm0, %xmm1
|
||||
; SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
|
||||
; SSE-NEXT: pand %xmm2, %xmm1
|
||||
; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm2[1,1,3,3]
|
||||
; SSE-NEXT: por %xmm1, %xmm0
|
||||
; SSE-NEXT: pand {{.*}}(%rip), %xmm0
|
||||
; SSE-NEXT: retq
|
||||
;
|
||||
; AVX-LABEL: ossfuzz21167:
|
||||
; AVX: # %bb.0: # %BB
|
||||
; AVX-NEXT: vpsllq $27, %xmm1, %xmm0
|
||||
; AVX-NEXT: vpsrad $27, %xmm0, %xmm1
|
||||
; AVX-NEXT: vpsrlq $27, %xmm0, %xmm0
|
||||
; AVX-NEXT: vpblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5],xmm1[6,7]
|
||||
; AVX-NEXT: vpxor %xmm1, %xmm1, %xmm1
|
||||
; AVX-NEXT: vpcmpgtq %xmm1, %xmm0, %xmm0
|
||||
; AVX-NEXT: vpsrlq $63, %xmm0, %xmm0
|
||||
; AVX-NEXT: retq
|
||||
BB:
|
||||
%c0 = icmp sgt <2 x i37> %y, zeroinitializer
|
||||
%xor_x = xor <2 x i37> undef, undef
|
||||
%smax96 = select <2 x i1> %c0, <2 x i37> %xor_x, <2 x i37> zeroinitializer
|
||||
ret <2 x i37> %smax96
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user