blob: f828b2d1ad4b588c40db48e5c9c60c142a345299 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test moves between FPRs and GPRs.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Test 32-bit moves from GPRs to FPRs. The GPR must be moved into the high
6; 32 bits of the FPR.
7define float @f1(i32 %a) {
8; CHECK: f1:
9; CHECK: sllg [[REGISTER:%r[0-5]]], %r2, 32
10; CHECK: ldgr %f0, [[REGISTER]]
11 %res = bitcast i32 %a to float
12 ret float %res
13}
14
15; Like f1, but create a situation where the shift can be folded with
16; surrounding code.
17define float @f2(i64 %big) {
18; CHECK: f2:
Richard Sandifordea9b6aa2013-07-11 09:10:09 +000019; CHECK: risbg [[REGISTER:%r[0-5]]], %r2, 0, 159, 31
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000020; CHECK: ldgr %f0, [[REGISTER]]
21 %shift = lshr i64 %big, 1
22 %a = trunc i64 %shift to i32
23 %res = bitcast i32 %a to float
24 ret float %res
25}
26
27; Another example of the same thing.
28define float @f3(i64 %big) {
29; CHECK: f3:
Richard Sandifordea9b6aa2013-07-11 09:10:09 +000030; CHECK: risbg [[REGISTER:%r[0-5]]], %r2, 0, 159, 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000031; CHECK: ldgr %f0, [[REGISTER]]
32 %shift = ashr i64 %big, 30
33 %a = trunc i64 %shift to i32
34 %res = bitcast i32 %a to float
35 ret float %res
36}
37
38; Like f1, but the value to transfer is already in the high 32 bits.
39define float @f4(i64 %big) {
40; CHECK: f4:
41; CHECK-NOT: %r2
Richard Sandiford84f54a32013-07-11 08:59:12 +000042; CHECK: risbg [[REG:%r[0-5]]], %r2, 0, 159, 0
43; CHECK-NOT: [[REG]]
44; CHECK: ldgr %f0, [[REG]]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000045 %shift = ashr i64 %big, 32
46 %a = trunc i64 %shift to i32
47 %res = bitcast i32 %a to float
48 ret float %res
49}
50
51; Test 64-bit moves from GPRs to FPRs.
52define double @f5(i64 %a) {
53; CHECK: f5:
54; CHECK: ldgr %f0, %r2
55 %res = bitcast i64 %a to double
56 ret double %res
57}
58
59; Test 128-bit moves from GPRs to FPRs. i128 isn't a legitimate type,
60; so this goes through memory.
Richard Sandiford97846492013-07-09 09:46:39 +000061; FIXME: it would be better to use one MVC here.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000062define void @f6(fp128 *%a, i128 *%b) {
63; CHECK: f6:
64; CHECK: lg
Richard Sandiford97846492013-07-09 09:46:39 +000065; CHECK: mvc
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000066; CHECK: stg
Richard Sandiford97846492013-07-09 09:46:39 +000067; CHECK: br %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000068 %val = load i128 *%b
69 %res = bitcast i128 %val to fp128
70 store fp128 %res, fp128 *%a
71 ret void
72}
73
74; Test 32-bit moves from FPRs to GPRs. The high 32 bits of the FPR should
75; be moved into the low 32 bits of the GPR.
76define i32 @f7(float %a) {
77; CHECK: f7:
78; CHECK: lgdr [[REGISTER:%r[0-5]]], %f0
79; CHECK: srlg %r2, [[REGISTER]], 32
80 %res = bitcast float %a to i32
81 ret i32 %res
82}
83
84; Test 64-bit moves from FPRs to GPRs.
85define i64 @f8(double %a) {
86; CHECK: f8:
87; CHECK: lgdr %r2, %f0
88 %res = bitcast double %a to i64
89 ret i64 %res
90}
91
92; Test 128-bit moves from FPRs to GPRs, with the same restriction as f6.
93define void @f9(fp128 *%a, i128 *%b) {
94; CHECK: f9:
95; CHECK: ld
96; CHECK: ld
97; CHECK: std
98; CHECK: std
99 %val = load fp128 *%a
100 %res = bitcast fp128 %val to i128
101 store i128 %res, i128 *%b
102 ret void
103}
104