From cf1bccf15c3582f0d59297a5feeb00080ca2c5f6 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sat, 1 Apr 2023 20:19:27 +0100 Subject: [PATCH] [X86] Add test showing failure to fold testc(X,~X) -> testc(X,-1) --- llvm/test/CodeGen/X86/combine-ptest.ll | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/llvm/test/CodeGen/X86/combine-ptest.ll b/llvm/test/CodeGen/X86/combine-ptest.ll index 2b9edb1..bff6d5f 100644 --- a/llvm/test/CodeGen/X86/combine-ptest.ll +++ b/llvm/test/CodeGen/X86/combine-ptest.ll @@ -150,6 +150,26 @@ define i32 @ptestnzc_256_invert0_commute(<4 x i64> %c, <4 x i64> %d, i32 %a, i32 } ; +; TODO: testc(X,~X) -> testc(X,-1) +; + +define i32 @ptestc_128_not(<2 x i64> %c, <2 x i64> %d, i32 %a, i32 %b) { +; CHECK-LABEL: ptestc_128_not: +; CHECK: # %bb.0: +; CHECK-NEXT: movl %edi, %eax +; CHECK-NEXT: vpcmpeqd %xmm1, %xmm1, %xmm1 +; CHECK-NEXT: vpxor %xmm1, %xmm0, %xmm1 +; CHECK-NEXT: vptest %xmm1, %xmm0 +; CHECK-NEXT: cmovael %esi, %eax +; CHECK-NEXT: retq + %t1 = xor <2 x i64> %c, + %t2 = call i32 @llvm.x86.sse41.ptestc(<2 x i64> %c, <2 x i64> %t1) + %t3 = icmp ne i32 %t2, 0 + %t4 = select i1 %t3, i32 %a, i32 %b + ret i32 %t4 +} + +; ; testz(AND(X,Y),AND(X,Y)) -> testz(X,Y) ; -- 2.7.4