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(i16 *%ptr) {
8 ; CHECK: mvhhi 0(%r2), 0
10 store i16 0, i16 *%ptr
14 ; Check the high end of the signed range.
15 define void @f2(i16 *%ptr) {
17 ; CHECK: mvhhi 0(%r2), 32767
19 store i16 32767, i16 *%ptr
23 ; Check the next value up.
24 define void @f3(i16 *%ptr) {
26 ; CHECK: mvhhi 0(%r2), -32768
28 store i16 -32768, i16 *%ptr
32 ; Check the high end of the unsigned range.
33 define void @f4(i16 *%ptr) {
35 ; CHECK: mvhhi 0(%r2), -1
37 store i16 65535, i16 *%ptr
42 define void @f5(i16 *%ptr) {
44 ; CHECK: mvhhi 0(%r2), -1
46 store i16 -1, i16 *%ptr
50 ; Check the low end of the signed range.
51 define void @f6(i16 *%ptr) {
53 ; CHECK: mvhhi 0(%r2), -32768
55 store i16 -32768, i16 *%ptr
59 ; Check the next value down.
60 define void @f7(i16 *%ptr) {
62 ; CHECK: mvhhi 0(%r2), 32767
64 store i16 -32769, i16 *%ptr
68 ; Check the high end of the MVHHI range.
69 define void @f8(i16 *%a) {
71 ; CHECK: mvhhi 4094(%r2), 42
73 %ptr = getelementptr i16, i16 *%a, i64 2047
74 store i16 42, i16 *%ptr
78 ; Check the next halfword up, which is out of range. We prefer STHY
80 define void @f9(i16 *%a) {
82 ; CHECK: lhi [[TMP:%r[0-5]]], 42
83 ; CHECK: sthy [[TMP]], 4096(%r2)
85 %ptr = getelementptr i16, i16 *%a, i64 2048
86 store i16 42, i16 *%ptr
90 ; Check negative displacements, for which we again prefer STHY.
91 define void @f10(i16 *%a) {
93 ; CHECK: lhi [[TMP:%r[0-5]]], 42
94 ; CHECK: sthy [[TMP]], -2(%r2)
96 %ptr = getelementptr i16, i16 *%a, i64 -1
97 store i16 42, i16 *%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 i16 *
109 store i16 42, i16 *%ptr