[llvm] cf1bccf - [X86] Add test showing failure to fold testc(X,~X) -> testc(X,-1)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 1 12:29:24 PDT 2023


Author: Simon Pilgrim
Date: 2023-04-01T20:28:30+01:00
New Revision: cf1bccf15c3582f0d59297a5feeb00080ca2c5f6

URL: https://github.com/llvm/llvm-project/commit/cf1bccf15c3582f0d59297a5feeb00080ca2c5f6
DIFF: https://github.com/llvm/llvm-project/commit/cf1bccf15c3582f0d59297a5feeb00080ca2c5f6.diff

LOG: [X86] Add test showing failure to fold testc(X,~X) -> testc(X,-1)

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/combine-ptest.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/combine-ptest.ll b/llvm/test/CodeGen/X86/combine-ptest.ll
index 2b9edb1c0a62..bff6d5fc0479 100644
--- a/llvm/test/CodeGen/X86/combine-ptest.ll
+++ b/llvm/test/CodeGen/X86/combine-ptest.ll
@@ -149,6 +149,26 @@ define i32 @ptestnzc_256_invert0_commute(<4 x i64> %c, <4 x i64> %d, i32 %a, i32
   ret i32 %t4
 }
 
+;
+; 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)
 ;


        


More information about the llvm-commits mailing list