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