[llvm] 2523fe8 - [X86] Add second PR47603 test case

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 5 03:40:48 PDT 2021


Author: Simon Pilgrim
Date: 2021-04-05T11:40:36+01:00
New Revision: 2523fe8a6895ee3affe0bdb04629451279dd97e4

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

LOG: [X86] Add second PR47603 test case

We had coverage for the xor(trunc(xor(x,31)),31) case but not xor(zext(xor(x,31)),31)

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/clz.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/clz.ll b/llvm/test/CodeGen/X86/clz.ll
index 8fa5adba51834..e11ab384c0119 100644
--- a/llvm/test/CodeGen/X86/clz.ll
+++ b/llvm/test/CodeGen/X86/clz.ll
@@ -1061,27 +1061,27 @@ define i64 @cttz_i64_zero_test_knownneverzero(i64 %n) {
 }
 
 ; Ensure we fold away the XOR(TRUNC(XOR(BSR(X),31)),31).
-define i8 @PR47603(i32 %0) {
-; X86-LABEL: PR47603:
+define i8 @PR47603_trunc(i32 %0) {
+; X86-LABEL: PR47603_trunc:
 ; X86:       # %bb.0:
 ; X86-NEXT:    bsrl {{[0-9]+}}(%esp), %eax
 ; X86-NEXT:    # kill: def $al killed $al killed $eax
 ; X86-NEXT:    retl
 ;
-; X64-LABEL: PR47603:
+; X64-LABEL: PR47603_trunc:
 ; X64:       # %bb.0:
 ; X64-NEXT:    bsrl %edi, %eax
 ; X64-NEXT:    # kill: def $al killed $al killed $eax
 ; X64-NEXT:    retq
 ;
-; X86-CLZ-LABEL: PR47603:
+; X86-CLZ-LABEL: PR47603_trunc:
 ; X86-CLZ:       # %bb.0:
 ; X86-CLZ-NEXT:    lzcntl {{[0-9]+}}(%esp), %eax
 ; X86-CLZ-NEXT:    xorb $31, %al
 ; X86-CLZ-NEXT:    # kill: def $al killed $al killed $eax
 ; X86-CLZ-NEXT:    retl
 ;
-; X64-CLZ-LABEL: PR47603:
+; X64-CLZ-LABEL: PR47603_trunc:
 ; X64-CLZ:       # %bb.0:
 ; X64-CLZ-NEXT:    lzcntl %edi, %eax
 ; X64-CLZ-NEXT:    xorb $31, %al
@@ -1092,3 +1092,43 @@ define i8 @PR47603(i32 %0) {
   %4 = trunc i32 %3 to i8
   ret i8 %4
 }
+
+; Ensure we fold away the XOR(ZEXT(XOR(BSR(X),31)),31).
+define i32 @PR47603_zext(i32 %a0, [32 x i8]* %a1) {
+; X86-LABEL: PR47603_zext:
+; X86:       # %bb.0:
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    bsrl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:    movsbl (%eax,%ecx), %eax
+; X86-NEXT:    retl
+;
+; X64-LABEL: PR47603_zext:
+; X64:       # %bb.0:
+; X64-NEXT:    bsrl %edi, %eax
+; X64-NEXT:    xorl $31, %eax
+; X64-NEXT:    xorq $31, %rax
+; X64-NEXT:    movsbl (%rsi,%rax), %eax
+; X64-NEXT:    retq
+;
+; X86-CLZ-LABEL: PR47603_zext:
+; X86-CLZ:       # %bb.0:
+; X86-CLZ-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT:    lzcntl {{[0-9]+}}(%esp), %ecx
+; X86-CLZ-NEXT:    xorl $31, %ecx
+; X86-CLZ-NEXT:    movsbl (%eax,%ecx), %eax
+; X86-CLZ-NEXT:    retl
+;
+; X64-CLZ-LABEL: PR47603_zext:
+; X64-CLZ:       # %bb.0:
+; X64-CLZ-NEXT:    lzcntl %edi, %eax
+; X64-CLZ-NEXT:    xorq $31, %rax
+; X64-CLZ-NEXT:    movsbl (%rsi,%rax), %eax
+; X64-CLZ-NEXT:    retq
+  %ctlz = tail call i32 @llvm.ctlz.i32(i32 %a0, i1 true)
+  %xor = xor i32 %ctlz, 31
+  %zext = zext i32 %xor to i64
+  %gep = getelementptr inbounds [32 x i8], [32 x i8]* %a1, i64 0, i64 %zext
+  %load = load i8, i8* %gep, align 1
+  %sext = sext i8 %load to i32
+  ret i32 %sext
+}


        


More information about the llvm-commits mailing list