[llvm] 4abcf7e - [x86] add tests for store merging (PR46662); NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 13:19:57 PDT 2020


Author: Sanjay Patel
Date: 2020-08-14T16:19:44-04:00
New Revision: 4abcf7e81c9adcc7168825e21ab97ad93be0e83a

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

LOG: [x86] add tests for store merging (PR46662); NFC

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/stores-merging.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/stores-merging.ll b/llvm/test/CodeGen/X86/stores-merging.ll
index 60fd01eac0960..4467fec9f2b45 100644
--- a/llvm/test/CodeGen/X86/stores-merging.ll
+++ b/llvm/test/CodeGen/X86/stores-merging.ll
@@ -428,3 +428,139 @@ define void @rotate32_twice(i16* %p) {
   store i16 %i2, i16* %p55, align 2
   ret void
 }
+
+define void @trunc_i16_to_i8(i16 %x, i8* %p) {
+; CHECK-LABEL: trunc_i16_to_i8:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movw %di, (%rsi)
+; CHECK-NEXT:    retq
+  %t1 = trunc i16 %x to i8
+  %sh = lshr i16 %x, 8
+  %t2 = trunc i16 %sh to i8
+  store i8 %t1, i8* %p, align 1
+  %p1 = getelementptr inbounds i8, i8* %p, i64 1
+  store i8 %t2, i8* %p1, align 1
+  ret void
+}
+
+define void @trunc_i32_to_i8(i32 %x, i8* %p) {
+; CHECK-LABEL: trunc_i32_to_i8:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movl %edi, (%rsi)
+; CHECK-NEXT:    retq
+  %t1 = trunc i32 %x to i8
+  %sh1 = lshr i32 %x, 8
+  %t2 = trunc i32 %sh1 to i8
+  %sh2 = lshr i32 %x, 16
+  %t3 = trunc i32 %sh2 to i8
+  %sh3 = lshr i32 %x, 24
+  %t4 = trunc i32 %sh3 to i8
+  store i8 %t1, i8* %p, align 1
+  %p1 = getelementptr inbounds i8, i8* %p, i64 1
+  store i8 %t2, i8* %p1, align 1
+  %p2 = getelementptr inbounds i8, i8* %p, i64 2
+  store i8 %t3, i8* %p2, align 1
+  %p3 = getelementptr inbounds i8, i8* %p, i64 3
+  store i8 %t4, i8* %p3, align 1
+  ret void
+}
+
+define void @trunc_i32_to_i16(i32 %x, i16* %p) {
+; CHECK-LABEL: trunc_i32_to_i16:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movw %di, (%rsi)
+; CHECK-NEXT:    shrl $16, %edi
+; CHECK-NEXT:    movw %di, 2(%rsi)
+; CHECK-NEXT:    retq
+  %t1 = trunc i32 %x to i16
+  %sh = lshr i32 %x, 16
+  %t2 = trunc i32 %sh to i16
+  store i16 %t1, i16* %p, align 2
+  %p1 = getelementptr inbounds i16, i16* %p, i64 1
+  store i16 %t2, i16* %p1, align 2
+  ret void
+}
+
+define void @trunc_i64_to_i8(i64 %x, i8* %p) {
+; CHECK-LABEL: trunc_i64_to_i8:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movq %rdi, (%rsi)
+; CHECK-NEXT:    retq
+  %t1 = trunc i64 %x to i8
+  %sh1 = lshr i64 %x, 8
+  %t2 = trunc i64 %sh1 to i8
+  %sh2 = lshr i64 %x, 16
+  %t3 = trunc i64 %sh2 to i8
+  %sh3 = lshr i64 %x, 24
+  %t4 = trunc i64 %sh3 to i8
+  %sh4 = lshr i64 %x, 32
+  %t5 = trunc i64 %sh4 to i8
+  %sh5 = lshr i64 %x, 40
+  %t6 = trunc i64 %sh5 to i8
+  %sh6 = lshr i64 %x, 48
+  %t7 = trunc i64 %sh6 to i8
+  %sh7 = lshr i64 %x, 56
+  %t8 = trunc i64 %sh7 to i8
+  store i8 %t1, i8* %p, align 1
+  %p1 = getelementptr inbounds i8, i8* %p, i64 1
+  store i8 %t2, i8* %p1, align 1
+  %p2 = getelementptr inbounds i8, i8* %p, i64 2
+  store i8 %t3, i8* %p2, align 1
+  %p3 = getelementptr inbounds i8, i8* %p, i64 3
+  store i8 %t4, i8* %p3, align 1
+  %p4 = getelementptr inbounds i8, i8* %p, i64 4
+  store i8 %t5, i8* %p4, align 1
+  %p5 = getelementptr inbounds i8, i8* %p, i64 5
+  store i8 %t6, i8* %p5, align 1
+  %p6 = getelementptr inbounds i8, i8* %p, i64 6
+  store i8 %t7, i8* %p6, align 1
+  %p7 = getelementptr inbounds i8, i8* %p, i64 7
+  store i8 %t8, i8* %p7, align 1
+  ret void
+}
+
+define void @trunc_i64_to_i16(i64 %x, i16* %p) {
+; CHECK-LABEL: trunc_i64_to_i16:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movq %rdi, %rax
+; CHECK-NEXT:    movq %rdi, %rcx
+; CHECK-NEXT:    movw %di, (%rsi)
+; CHECK-NEXT:    shrq $16, %rdi
+; CHECK-NEXT:    shrq $32, %rax
+; CHECK-NEXT:    shrq $48, %rcx
+; CHECK-NEXT:    movw %di, 2(%rsi)
+; CHECK-NEXT:    movw %ax, 4(%rsi)
+; CHECK-NEXT:    movw %cx, 6(%rsi)
+; CHECK-NEXT:    retq
+  %t1 = trunc i64 %x to i16
+  %sh1 = lshr i64 %x, 16
+  %t2 = trunc i64 %sh1 to i16
+  %sh2 = lshr i64 %x, 32
+  %t3 = trunc i64 %sh2 to i16
+  %sh3 = lshr i64 %x, 48
+  %t4 = trunc i64 %sh3 to i16
+  store i16 %t1, i16* %p, align 2
+  %p1 = getelementptr inbounds i16, i16* %p, i64 1
+  store i16 %t2, i16* %p1, align 2
+  %p2 = getelementptr inbounds i16, i16* %p, i64 2
+  store i16 %t3, i16* %p2, align 2
+  %p3 = getelementptr inbounds i16, i16* %p, i64 3
+  store i16 %t4, i16* %p3, align 2
+  ret void
+}
+
+define void @trunc_i64_to_i32(i64 %x, i32* %p) {
+; CHECK-LABEL: trunc_i64_to_i32:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movl %edi, (%rsi)
+; CHECK-NEXT:    shrq $32, %rdi
+; CHECK-NEXT:    movl %edi, 4(%rsi)
+; CHECK-NEXT:    retq
+  %t1 = trunc i64 %x to i32
+  %sh = lshr i64 %x, 32
+  %t2 = trunc i64 %sh to i32
+  store i32 %t1, i32* %p, align 4
+  %p1 = getelementptr inbounds i32, i32* %p, i64 1
+  store i32 %t2, i32* %p1, align 4
+  ret void
+}


        


More information about the llvm-commits mailing list