1 ; Test moves of integers to 2-byte memory locations.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check the low end of the unsigned range.
6 define void @f1(ptr %ptr) {
8 ; CHECK: mvhhi 0(%r2), 0
14 ; Check the high end of the signed range.
15 define void @f2(ptr %ptr) {
17 ; CHECK: mvhhi 0(%r2), 32767
19 store i16 32767, ptr %ptr
23 ; Check the next value up.
24 define void @f3(ptr %ptr) {
26 ; CHECK: mvhhi 0(%r2), -32768
28 store i16 -32768, ptr %ptr
32 ; Check the high end of the unsigned range.
33 define void @f4(ptr %ptr) {
35 ; CHECK: mvhhi 0(%r2), -1
37 store i16 65535, ptr %ptr
42 define void @f5(ptr %ptr) {
44 ; CHECK: mvhhi 0(%r2), -1
46 store i16 -1, ptr %ptr
50 ; Check the low end of the signed range.
51 define void @f6(ptr %ptr) {
53 ; CHECK: mvhhi 0(%r2), -32768
55 store i16 -32768, ptr %ptr
59 ; Check the next value down.
60 define void @f7(ptr %ptr) {
62 ; CHECK: mvhhi 0(%r2), 32767
64 store i16 -32769, ptr %ptr
68 ; Check the high end of the MVHHI range.
69 define void @f8(ptr %a) {
71 ; CHECK: mvhhi 4094(%r2), 42
73 %ptr = getelementptr i16, ptr %a, i64 2047
74 store i16 42, ptr %ptr
78 ; Check the next halfword up, which is out of range. We prefer STHY
80 define void @f9(ptr %a) {
82 ; CHECK: lhi [[TMP:%r[0-5]]], 42
83 ; CHECK: sthy [[TMP]], 4096(%r2)
85 %ptr = getelementptr i16, ptr %a, i64 2048
86 store i16 42, ptr %ptr
90 ; Check negative displacements, for which we again prefer STHY.
91 define void @f10(ptr %a) {
93 ; CHECK: lhi [[TMP:%r[0-5]]], 42
94 ; CHECK: sthy [[TMP]], -2(%r2)
96 %ptr = getelementptr i16, ptr %a, i64 -1
97 store i16 42, ptr %ptr
101 ; Check that MVHHI does not allow an index.
102 define void @f11(i64 %src, i64 %index) {
104 ; CHECK: lhi [[TMP:%r[0-5]]], 42
105 ; CHECK: sth [[TMP]], 0({{%r2,%r3|%r3,%r2}})
107 %add = add i64 %src, %index
108 %ptr = inttoptr i64 %add to ptr
109 store i16 42, ptr %ptr