1 ; Test 64-bit byteswaps from registers to memory.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 declare i64 @llvm.bswap.i64(i64 %a)
7 ; Check STRVG with no displacement.
8 define void @f1(i64 *%dst, i64 %a) {
10 ; CHECK: strvg %r3, 0(%r2)
12 %swapped = call i64 @llvm.bswap.i64(i64 %a)
13 store i64 %swapped, i64 *%dst
17 ; Check the high end of the aligned STRVG range.
18 define void @f2(i64 *%dst, i64 %a) {
20 ; CHECK: strvg %r3, 524280(%r2)
22 %ptr = getelementptr i64, i64 *%dst, i64 65535
23 %swapped = call i64 @llvm.bswap.i64(i64 %a)
24 store i64 %swapped, i64 *%ptr
28 ; Check the next doubleword up, which needs separate address logic.
29 ; Other sequences besides this one would be OK.
30 define void @f3(i64 *%dst, i64 %a) {
32 ; CHECK: agfi %r2, 524288
33 ; CHECK: strvg %r3, 0(%r2)
35 %ptr = getelementptr i64, i64 *%dst, i64 65536
36 %swapped = call i64 @llvm.bswap.i64(i64 %a)
37 store i64 %swapped, i64 *%ptr
41 ; Check the high end of the negative aligned STRVG range.
42 define void @f4(i64 *%dst, i64 %a) {
44 ; CHECK: strvg %r3, -8(%r2)
46 %ptr = getelementptr i64, i64 *%dst, i64 -1
47 %swapped = call i64 @llvm.bswap.i64(i64 %a)
48 store i64 %swapped, i64 *%ptr
52 ; Check the low end of the STRVG range.
53 define void @f5(i64 *%dst, i64 %a) {
55 ; CHECK: strvg %r3, -524288(%r2)
57 %ptr = getelementptr i64, i64 *%dst, i64 -65536
58 %swapped = call i64 @llvm.bswap.i64(i64 %a)
59 store i64 %swapped, i64 *%ptr
63 ; Check the next doubleword down, which needs separate address logic.
64 ; Other sequences besides this one would be OK.
65 define void @f6(i64 *%dst, i64 %a) {
67 ; CHECK: agfi %r2, -524296
68 ; CHECK: strvg %r3, 0(%r2)
70 %ptr = getelementptr i64, i64 *%dst, i64 -65537
71 %swapped = call i64 @llvm.bswap.i64(i64 %a)
72 store i64 %swapped, i64 *%ptr
76 ; Check that STRVG allows an index.
77 define void @f7(i64 %src, i64 %index, i64 %a) {
79 ; CHECK: strvg %r4, 524287({{%r3,%r2|%r2,%r3}})
81 %add1 = add i64 %src, %index
82 %add2 = add i64 %add1, 524287
83 %ptr = inttoptr i64 %add2 to i64 *
84 %swapped = call i64 @llvm.bswap.i64(i64 %a)
85 store i64 %swapped, i64 *%ptr