From fa4347261e76e37f9632fe010e2e7beae97d117b Mon Sep 17 00:00:00 2001 From: "Luo, Yuanke" Date: Thu, 21 Apr 2022 21:38:55 +0800 Subject: [PATCH] [X86] Add test case for SetCCMOVMSK combine. Create 2 users for MOVMSK to test if compiler would perform the combine "MOVMSK(CONCAT(X,Y)) == 0 -> MOVMSK(OR(X,Y))". --- .../test/CodeGen/X86/vector-compare-any_of.ll | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/llvm/test/CodeGen/X86/vector-compare-any_of.ll b/llvm/test/CodeGen/X86/vector-compare-any_of.ll index 5a5efa7735da..166584420837 100644 --- a/llvm/test/CodeGen/X86/vector-compare-any_of.ll +++ b/llvm/test/CodeGen/X86/vector-compare-any_of.ll @@ -1330,3 +1330,58 @@ define i1 @bool_reduction_v32i8(<32 x i8> %x, <32 x i8> %y) { %g = extractelement <32 x i1> %f, i32 0 ret i1 %g } + +define {i32, i1} @test_v16i8_muti_uses(<16 x i8> %x, <16 x i8>%y, <16 x i8> %z) { +; SSE-LABEL: test_v16i8_muti_uses: +; SSE: # %bb.0: +; SSE-NEXT: pcmpeqb %xmm1, %xmm0 +; SSE-NEXT: pcmpeqb %xmm1, %xmm2 +; SSE-NEXT: pmovmskb %xmm0, %ecx +; SSE-NEXT: pmovmskb %xmm2, %eax +; SSE-NEXT: shll $16, %eax +; SSE-NEXT: orl %ecx, %eax +; SSE-NEXT: sete %dl +; SSE-NEXT: retq +; +; AVX1-LABEL: test_v16i8_muti_uses: +; AVX1: # %bb.0: +; AVX1-NEXT: vpcmpeqb %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vpcmpeqb %xmm1, %xmm2, %xmm1 +; AVX1-NEXT: vpmovmskb %xmm0, %ecx +; AVX1-NEXT: vpmovmskb %xmm1, %eax +; AVX1-NEXT: shll $16, %eax +; AVX1-NEXT: orl %ecx, %eax +; AVX1-NEXT: sete %dl +; AVX1-NEXT: retq +; +; AVX2-LABEL: test_v16i8_muti_uses: +; AVX2: # %bb.0: +; AVX2-NEXT: vpcmpeqb %xmm1, %xmm0, %xmm0 +; AVX2-NEXT: vpcmpeqb %xmm1, %xmm2, %xmm1 +; AVX2-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm2 +; AVX2-NEXT: vpmovmskb %ymm2, %eax +; AVX2-NEXT: vpor %xmm1, %xmm0, %xmm0 +; AVX2-NEXT: vpmovmskb %xmm0, %ecx +; AVX2-NEXT: testl %ecx, %ecx +; AVX2-NEXT: sete %dl +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: test_v16i8_muti_uses: +; AVX512: # %bb.0: +; AVX512-NEXT: vpcmpeqb %xmm1, %xmm0, %k0 +; AVX512-NEXT: vpcmpeqb %xmm1, %xmm2, %k1 +; AVX512-NEXT: kunpckwd %k0, %k1, %k0 +; AVX512-NEXT: kortestd %k0, %k0 +; AVX512-NEXT: kmovd %k0, %eax +; AVX512-NEXT: sete %dl +; AVX512-NEXT: retq + %t1 = icmp eq <16 x i8> %x, %y + %t2 = icmp eq <16 x i8> %z, %y + %a = shufflevector <16 x i1> %t1, <16 x i1> %t2, <32 x i32> + %b = bitcast <32 x i1> %a to i32 + %c = icmp eq i32 %b, 0 + %r1 = insertvalue {i32, i1} poison, i32 %b, 0 + %r2 = insertvalue {i32, i1} %r1, i1 %c, 1 + ret {i32, i1} %r2 +}