[llvm] ebeb191 - [X86] Add bswap(shl()) test

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 19 09:38:33 PST 2022


Author: Simon Pilgrim
Date: 2022-02-19T17:37:07Z
New Revision: ebeb191b65feec74d54cec574e6bcae9f269cf8b

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

LOG: [X86] Add bswap(shl()) test

Test based off issues #51391 and #53867 - we're going to end up needing InstCombine + DAG variants of this fold as DAG can create BSWAP nodes as part of load folding

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/combine-bswap.ll b/llvm/test/CodeGen/X86/combine-bswap.ll
index 4fbb3bf98171..2d262935f813 100644
--- a/llvm/test/CodeGen/X86/combine-bswap.ll
+++ b/llvm/test/CodeGen/X86/combine-bswap.ll
@@ -6,6 +6,7 @@
 ; actual output is massive at the moment as llvm.bswap is not yet legal.
 
 declare i32 @llvm.bswap.i32(i32) readnone
+declare i64 @llvm.bswap.i64(i64) readnone
 declare i32 @llvm.bswap.v4i32(i32) readnone
 
 ; fold (bswap undef) -> undef
@@ -82,3 +83,24 @@ define void @demand_one_loaded_byte(i64* %xp, i32* %yp) {
   store i32 %r, i32* %yp, align 4
   ret void
 }
+
+define i64 @test_bswap_shift(i16 %0) {
+; X86-LABEL: test_bswap_shift:
+; X86:       # %bb.0:
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    shll $16, %eax
+; X86-NEXT:    bswapl %eax
+; X86-NEXT:    xorl %edx, %edx
+; X86-NEXT:    retl
+;
+; X64-LABEL: test_bswap_shift:
+; X64:       # %bb.0:
+; X64-NEXT:    movl %edi, %eax
+; X64-NEXT:    shlq $48, %rax
+; X64-NEXT:    bswapq %rax
+; X64-NEXT:    retq
+  %2 = zext i16 %0 to i64
+  %3 = shl i64 %2, 48
+  %4 = call i64 @llvm.bswap.i64(i64 %3)
+  ret i64 %4
+}


        


More information about the llvm-commits mailing list