[llvm] f504431 - [NFC][X86] Adjust multi-use tests in clear-lowbits.ll, add 'misc' tests

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 7 12:55:42 PDT 2021


Author: Roman Lebedev
Date: 2021-09-07T22:55:15+03:00
New Revision: f504431f03a35739d33402c880aa2c7a9a8fd79f

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

LOG: [NFC][X86] Adjust multi-use tests in clear-lowbits.ll, add 'misc' tests

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/clear-lowbits.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/clear-lowbits.ll b/llvm/test/CodeGen/X86/clear-lowbits.ll
index d677dc41e484..ebf60d8b7080 100644
--- a/llvm/test/CodeGen/X86/clear-lowbits.ll
+++ b/llvm/test/CodeGen/X86/clear-lowbits.ll
@@ -1609,182 +1609,208 @@ define i64 @clear_lowbits64_ic4_commutative(i64 %val, i64 %numlowbits) nounwind
 ; Multi-use tests
 ; ---------------------------------------------------------------------------- ;
 
-declare void @use32(i32)
-declare void @use64(i64)
-
-define i32 @oneuse32(i32 %val, i32 %numlowbits) nounwind {
-; X86-NOBMI2-LABEL: oneuse32:
+define i32 @oneuse32_c(i32 %val, i32 %numlowbits, i32* %escape) nounwind {
+; X86-NOBMI2-LABEL: oneuse32_c:
 ; X86-NOBMI2:       # %bb.0:
-; X86-NOBMI2-NEXT:    pushl %esi
-; X86-NOBMI2-NEXT:    subl $8, %esp
+; X86-NOBMI2-NEXT:    movl {{[0-9]+}}(%esp), %edx
 ; X86-NOBMI2-NEXT:    movb {{[0-9]+}}(%esp), %cl
-; X86-NOBMI2-NEXT:    movl $-1, %esi
-; X86-NOBMI2-NEXT:    shll %cl, %esi
-; X86-NOBMI2-NEXT:    movl %esi, (%esp)
-; X86-NOBMI2-NEXT:    calll use32 at PLT
-; X86-NOBMI2-NEXT:    andl {{[0-9]+}}(%esp), %esi
-; X86-NOBMI2-NEXT:    movl %esi, %eax
-; X86-NOBMI2-NEXT:    addl $8, %esp
-; X86-NOBMI2-NEXT:    popl %esi
+; X86-NOBMI2-NEXT:    movl $-1, %eax
+; X86-NOBMI2-NEXT:    shll %cl, %eax
+; X86-NOBMI2-NEXT:    movl %eax, (%edx)
+; X86-NOBMI2-NEXT:    andl {{[0-9]+}}(%esp), %eax
 ; X86-NOBMI2-NEXT:    retl
 ;
-; X86-BMI2-LABEL: oneuse32:
+; X86-BMI2-LABEL: oneuse32_c:
 ; X86-BMI2:       # %bb.0:
-; X86-BMI2-NEXT:    pushl %esi
-; X86-BMI2-NEXT:    subl $8, %esp
+; X86-BMI2-NEXT:    movl {{[0-9]+}}(%esp), %ecx
 ; X86-BMI2-NEXT:    movb {{[0-9]+}}(%esp), %al
-; X86-BMI2-NEXT:    movl $-1, %ecx
-; X86-BMI2-NEXT:    shlxl %eax, %ecx, %esi
-; X86-BMI2-NEXT:    movl %esi, (%esp)
-; X86-BMI2-NEXT:    calll use32 at PLT
-; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %esi
-; X86-BMI2-NEXT:    movl %esi, %eax
-; X86-BMI2-NEXT:    addl $8, %esp
-; X86-BMI2-NEXT:    popl %esi
+; X86-BMI2-NEXT:    movl $-1, %edx
+; X86-BMI2-NEXT:    shlxl %eax, %edx, %eax
+; X86-BMI2-NEXT:    movl %eax, (%ecx)
+; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %eax
 ; X86-BMI2-NEXT:    retl
 ;
-; X64-NOBMI2-LABEL: oneuse32:
+; X64-NOBMI2-LABEL: oneuse32_c:
 ; X64-NOBMI2:       # %bb.0:
-; X64-NOBMI2-NEXT:    pushq %rbp
-; X64-NOBMI2-NEXT:    pushq %rbx
-; X64-NOBMI2-NEXT:    pushq %rax
 ; X64-NOBMI2-NEXT:    movl %esi, %ecx
-; X64-NOBMI2-NEXT:    movl %edi, %ebx
-; X64-NOBMI2-NEXT:    movl $-1, %ebp
+; X64-NOBMI2-NEXT:    movl $-1, %eax
 ; X64-NOBMI2-NEXT:    # kill: def $cl killed $cl killed $ecx
-; X64-NOBMI2-NEXT:    shll %cl, %ebp
-; X64-NOBMI2-NEXT:    movl %ebp, %edi
-; X64-NOBMI2-NEXT:    callq use32 at PLT
-; X64-NOBMI2-NEXT:    andl %ebx, %ebp
-; X64-NOBMI2-NEXT:    movl %ebp, %eax
-; X64-NOBMI2-NEXT:    addq $8, %rsp
-; X64-NOBMI2-NEXT:    popq %rbx
-; X64-NOBMI2-NEXT:    popq %rbp
+; X64-NOBMI2-NEXT:    shll %cl, %eax
+; X64-NOBMI2-NEXT:    movl %eax, (%rdx)
+; X64-NOBMI2-NEXT:    andl %edi, %eax
 ; X64-NOBMI2-NEXT:    retq
 ;
-; X64-BMI2-LABEL: oneuse32:
+; X64-BMI2-LABEL: oneuse32_c:
 ; X64-BMI2:       # %bb.0:
-; X64-BMI2-NEXT:    pushq %rbp
-; X64-BMI2-NEXT:    pushq %rbx
-; X64-BMI2-NEXT:    pushq %rax
-; X64-BMI2-NEXT:    movl %edi, %ebx
 ; X64-BMI2-NEXT:    movl $-1, %eax
-; X64-BMI2-NEXT:    shlxl %esi, %eax, %ebp
-; X64-BMI2-NEXT:    movl %ebp, %edi
-; X64-BMI2-NEXT:    callq use32 at PLT
-; X64-BMI2-NEXT:    andl %ebx, %ebp
-; X64-BMI2-NEXT:    movl %ebp, %eax
-; X64-BMI2-NEXT:    addq $8, %rsp
-; X64-BMI2-NEXT:    popq %rbx
-; X64-BMI2-NEXT:    popq %rbp
+; X64-BMI2-NEXT:    shlxl %esi, %eax, %eax
+; X64-BMI2-NEXT:    movl %eax, (%rdx)
+; X64-BMI2-NEXT:    andl %edi, %eax
 ; X64-BMI2-NEXT:    retq
   %mask = shl i32 -1, %numlowbits
-  call void @use32(i32 %mask)
+  store i32 %mask, i32* %escape
   %masked = and i32 %mask, %val
   ret i32 %masked
 }
 
-define i64 @oneuse64(i64 %val, i64 %numlowbits) nounwind {
+define i64 @oneuse64(i64 %val, i64 %numlowbits, i64* %escape) nounwind {
 ; X86-NOBMI2-LABEL: oneuse64:
 ; X86-NOBMI2:       # %bb.0:
 ; X86-NOBMI2-NEXT:    pushl %edi
 ; X86-NOBMI2-NEXT:    pushl %esi
-; X86-NOBMI2-NEXT:    pushl %eax
+; X86-NOBMI2-NEXT:    movl {{[0-9]+}}(%esp), %esi
 ; X86-NOBMI2-NEXT:    movb {{[0-9]+}}(%esp), %cl
-; X86-NOBMI2-NEXT:    movl $-1, %esi
-; X86-NOBMI2-NEXT:    movl $-1, %eax
-; X86-NOBMI2-NEXT:    shll %cl, %eax
-; X86-NOBMI2-NEXT:    xorl %edi, %edi
+; X86-NOBMI2-NEXT:    movl $-1, %edx
+; X86-NOBMI2-NEXT:    movl $-1, %edi
+; X86-NOBMI2-NEXT:    shll %cl, %edi
+; X86-NOBMI2-NEXT:    xorl %eax, %eax
 ; X86-NOBMI2-NEXT:    testb $32, %cl
 ; X86-NOBMI2-NEXT:    jne .LBB37_1
 ; X86-NOBMI2-NEXT:  # %bb.2:
-; X86-NOBMI2-NEXT:    movl %eax, %edi
+; X86-NOBMI2-NEXT:    movl %edi, %eax
 ; X86-NOBMI2-NEXT:    jmp .LBB37_3
 ; X86-NOBMI2-NEXT:  .LBB37_1:
-; X86-NOBMI2-NEXT:    movl %eax, %esi
+; X86-NOBMI2-NEXT:    movl %edi, %edx
 ; X86-NOBMI2-NEXT:  .LBB37_3:
-; X86-NOBMI2-NEXT:    subl $8, %esp
-; X86-NOBMI2-NEXT:    pushl %esi
-; X86-NOBMI2-NEXT:    pushl %edi
-; X86-NOBMI2-NEXT:    calll use64 at PLT
-; X86-NOBMI2-NEXT:    addl $16, %esp
-; X86-NOBMI2-NEXT:    andl {{[0-9]+}}(%esp), %edi
-; X86-NOBMI2-NEXT:    andl {{[0-9]+}}(%esp), %esi
-; X86-NOBMI2-NEXT:    movl %edi, %eax
-; X86-NOBMI2-NEXT:    movl %esi, %edx
-; X86-NOBMI2-NEXT:    addl $4, %esp
+; X86-NOBMI2-NEXT:    movl %edx, 4(%esi)
+; X86-NOBMI2-NEXT:    movl %eax, (%esi)
+; X86-NOBMI2-NEXT:    andl {{[0-9]+}}(%esp), %eax
+; X86-NOBMI2-NEXT:    andl {{[0-9]+}}(%esp), %edx
 ; X86-NOBMI2-NEXT:    popl %esi
 ; X86-NOBMI2-NEXT:    popl %edi
 ; X86-NOBMI2-NEXT:    retl
 ;
 ; X86-BMI2-LABEL: oneuse64:
 ; X86-BMI2:       # %bb.0:
-; X86-BMI2-NEXT:    pushl %edi
+; X86-BMI2-NEXT:    pushl %ebx
 ; X86-BMI2-NEXT:    pushl %esi
-; X86-BMI2-NEXT:    pushl %eax
-; X86-BMI2-NEXT:    movb {{[0-9]+}}(%esp), %cl
-; X86-BMI2-NEXT:    movl $-1, %esi
-; X86-BMI2-NEXT:    shlxl %ecx, %esi, %eax
-; X86-BMI2-NEXT:    xorl %edi, %edi
-; X86-BMI2-NEXT:    testb $32, %cl
+; X86-BMI2-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; X86-BMI2-NEXT:    movb {{[0-9]+}}(%esp), %bl
+; X86-BMI2-NEXT:    movl $-1, %edx
+; X86-BMI2-NEXT:    shlxl %ebx, %edx, %esi
+; X86-BMI2-NEXT:    xorl %eax, %eax
+; X86-BMI2-NEXT:    testb $32, %bl
 ; X86-BMI2-NEXT:    jne .LBB37_1
 ; X86-BMI2-NEXT:  # %bb.2:
-; X86-BMI2-NEXT:    movl %eax, %edi
+; X86-BMI2-NEXT:    movl %esi, %eax
 ; X86-BMI2-NEXT:    jmp .LBB37_3
 ; X86-BMI2-NEXT:  .LBB37_1:
-; X86-BMI2-NEXT:    movl %eax, %esi
-; X86-BMI2-NEXT:  .LBB37_3:
-; X86-BMI2-NEXT:    subl $8, %esp
-; X86-BMI2-NEXT:    pushl %esi
-; X86-BMI2-NEXT:    pushl %edi
-; X86-BMI2-NEXT:    calll use64 at PLT
-; X86-BMI2-NEXT:    addl $16, %esp
-; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %edi
-; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %esi
-; X86-BMI2-NEXT:    movl %edi, %eax
 ; X86-BMI2-NEXT:    movl %esi, %edx
-; X86-BMI2-NEXT:    addl $4, %esp
+; X86-BMI2-NEXT:  .LBB37_3:
+; X86-BMI2-NEXT:    movl %edx, 4(%ecx)
+; X86-BMI2-NEXT:    movl %eax, (%ecx)
+; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %eax
+; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %edx
 ; X86-BMI2-NEXT:    popl %esi
-; X86-BMI2-NEXT:    popl %edi
+; X86-BMI2-NEXT:    popl %ebx
 ; X86-BMI2-NEXT:    retl
 ;
 ; X64-NOBMI2-LABEL: oneuse64:
 ; X64-NOBMI2:       # %bb.0:
-; X64-NOBMI2-NEXT:    pushq %r14
-; X64-NOBMI2-NEXT:    pushq %rbx
-; X64-NOBMI2-NEXT:    pushq %rax
 ; X64-NOBMI2-NEXT:    movq %rsi, %rcx
-; X64-NOBMI2-NEXT:    movq %rdi, %r14
-; X64-NOBMI2-NEXT:    movq $-1, %rbx
+; X64-NOBMI2-NEXT:    movq $-1, %rax
 ; X64-NOBMI2-NEXT:    # kill: def $cl killed $cl killed $rcx
-; X64-NOBMI2-NEXT:    shlq %cl, %rbx
-; X64-NOBMI2-NEXT:    movq %rbx, %rdi
-; X64-NOBMI2-NEXT:    callq use64 at PLT
-; X64-NOBMI2-NEXT:    andq %r14, %rbx
-; X64-NOBMI2-NEXT:    movq %rbx, %rax
-; X64-NOBMI2-NEXT:    addq $8, %rsp
-; X64-NOBMI2-NEXT:    popq %rbx
-; X64-NOBMI2-NEXT:    popq %r14
+; X64-NOBMI2-NEXT:    shlq %cl, %rax
+; X64-NOBMI2-NEXT:    movq %rax, (%rdx)
+; X64-NOBMI2-NEXT:    andq %rdi, %rax
 ; X64-NOBMI2-NEXT:    retq
 ;
 ; X64-BMI2-LABEL: oneuse64:
 ; X64-BMI2:       # %bb.0:
-; X64-BMI2-NEXT:    pushq %r14
-; X64-BMI2-NEXT:    pushq %rbx
-; X64-BMI2-NEXT:    pushq %rax
-; X64-BMI2-NEXT:    movq %rdi, %r14
 ; X64-BMI2-NEXT:    movq $-1, %rax
-; X64-BMI2-NEXT:    shlxq %rsi, %rax, %rbx
-; X64-BMI2-NEXT:    movq %rbx, %rdi
-; X64-BMI2-NEXT:    callq use64 at PLT
-; X64-BMI2-NEXT:    andq %r14, %rbx
-; X64-BMI2-NEXT:    movq %rbx, %rax
-; X64-BMI2-NEXT:    addq $8, %rsp
-; X64-BMI2-NEXT:    popq %rbx
-; X64-BMI2-NEXT:    popq %r14
+; X64-BMI2-NEXT:    shlxq %rsi, %rax, %rax
+; X64-BMI2-NEXT:    movq %rax, (%rdx)
+; X64-BMI2-NEXT:    andq %rdi, %rax
 ; X64-BMI2-NEXT:    retq
   %mask = shl i64 -1, %numlowbits
-  call void @use64(i64 %mask)
+  store i64 %mask, i64* %escape
   %masked = and i64 %mask, %val
   ret i64 %masked
 }
+
+; ---------------------------------------------------------------------------- ;
+; Misc.
+;
+; Variation of pattern
+;   ic) x &  (-1 << (C - y))
+; but with C != bitwidth(x)
+; ---------------------------------------------------------------------------- ;
+
+define i32 @clear_lowbits32_16_ic0(i32 %val, i32 %numlowbits) nounwind {
+; X86-NOBMI2-LABEL: clear_lowbits32_16_ic0:
+; X86-NOBMI2:       # %bb.0:
+; X86-NOBMI2-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NOBMI2-NEXT:    movb $16, %cl
+; X86-NOBMI2-NEXT:    subb {{[0-9]+}}(%esp), %cl
+; X86-NOBMI2-NEXT:    shrl %cl, %eax
+; X86-NOBMI2-NEXT:    shll %cl, %eax
+; X86-NOBMI2-NEXT:    retl
+;
+; X86-BMI2-LABEL: clear_lowbits32_16_ic0:
+; X86-BMI2:       # %bb.0:
+; X86-BMI2-NEXT:    movb $16, %al
+; X86-BMI2-NEXT:    subb {{[0-9]+}}(%esp), %al
+; X86-BMI2-NEXT:    shrxl %eax, {{[0-9]+}}(%esp), %ecx
+; X86-BMI2-NEXT:    shlxl %eax, %ecx, %eax
+; X86-BMI2-NEXT:    retl
+;
+; X64-NOBMI2-LABEL: clear_lowbits32_16_ic0:
+; X64-NOBMI2:       # %bb.0:
+; X64-NOBMI2-NEXT:    movl %edi, %eax
+; X64-NOBMI2-NEXT:    movb $16, %cl
+; X64-NOBMI2-NEXT:    subb %sil, %cl
+; X64-NOBMI2-NEXT:    shrl %cl, %eax
+; X64-NOBMI2-NEXT:    shll %cl, %eax
+; X64-NOBMI2-NEXT:    retq
+;
+; X64-BMI2-LABEL: clear_lowbits32_16_ic0:
+; X64-BMI2:       # %bb.0:
+; X64-BMI2-NEXT:    movb $16, %al
+; X64-BMI2-NEXT:    subb %sil, %al
+; X64-BMI2-NEXT:    shrxl %eax, %edi, %ecx
+; X64-BMI2-NEXT:    shlxl %eax, %ecx, %eax
+; X64-BMI2-NEXT:    retq
+  %numhighbits = sub i32 16, %numlowbits
+  %mask = shl i32 -1, %numhighbits
+  %masked = and i32 %mask, %val
+  ret i32 %masked
+}
+define i32 @clear_lowbits32_48_ic0(i32 %val, i32 %numlowbits) nounwind {
+; X86-NOBMI2-LABEL: clear_lowbits32_48_ic0:
+; X86-NOBMI2:       # %bb.0:
+; X86-NOBMI2-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NOBMI2-NEXT:    movb $48, %cl
+; X86-NOBMI2-NEXT:    subb {{[0-9]+}}(%esp), %cl
+; X86-NOBMI2-NEXT:    shrl %cl, %eax
+; X86-NOBMI2-NEXT:    shll %cl, %eax
+; X86-NOBMI2-NEXT:    retl
+;
+; X86-BMI2-LABEL: clear_lowbits32_48_ic0:
+; X86-BMI2:       # %bb.0:
+; X86-BMI2-NEXT:    movb $48, %al
+; X86-BMI2-NEXT:    subb {{[0-9]+}}(%esp), %al
+; X86-BMI2-NEXT:    shrxl %eax, {{[0-9]+}}(%esp), %ecx
+; X86-BMI2-NEXT:    shlxl %eax, %ecx, %eax
+; X86-BMI2-NEXT:    retl
+;
+; X64-NOBMI2-LABEL: clear_lowbits32_48_ic0:
+; X64-NOBMI2:       # %bb.0:
+; X64-NOBMI2-NEXT:    movl %edi, %eax
+; X64-NOBMI2-NEXT:    movb $48, %cl
+; X64-NOBMI2-NEXT:    subb %sil, %cl
+; X64-NOBMI2-NEXT:    shrl %cl, %eax
+; X64-NOBMI2-NEXT:    shll %cl, %eax
+; X64-NOBMI2-NEXT:    retq
+;
+; X64-BMI2-LABEL: clear_lowbits32_48_ic0:
+; X64-BMI2:       # %bb.0:
+; X64-BMI2-NEXT:    movb $48, %al
+; X64-BMI2-NEXT:    subb %sil, %al
+; X64-BMI2-NEXT:    shrxl %eax, %edi, %ecx
+; X64-BMI2-NEXT:    shlxl %eax, %ecx, %eax
+; X64-BMI2-NEXT:    retq
+  %numhighbits = sub i32 48, %numlowbits
+  %mask = shl i32 -1, %numhighbits
+  %masked = and i32 %mask, %val
+  ret i32 %masked
+}


        


More information about the llvm-commits mailing list