[X86] Add test showing failure to fold testc(X,~X) -> testc(X,-1)
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 1 Apr 2023 19:19:27 +0000 (20:19 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 1 Apr 2023 19:28:30 +0000 (20:28 +0100)
llvm/test/CodeGen/X86/combine-ptest.ll

index 2b9edb1..bff6d5f 100644 (file)
@@ -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, <i64 -1, i64 -1>
+  %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)
 ;