Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 1 | ; 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. |
| 7 | define 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. |
| 17 | define float @f2(i64 %big) { |
| 18 | ; CHECK: f2: |
Richard Sandiford | ea9b6aa | 2013-07-11 09:10:09 +0000 | [diff] [blame] | 19 | ; CHECK: risbg [[REGISTER:%r[0-5]]], %r2, 0, 159, 31 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 20 | ; 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. |
| 28 | define float @f3(i64 %big) { |
| 29 | ; CHECK: f3: |
Richard Sandiford | ea9b6aa | 2013-07-11 09:10:09 +0000 | [diff] [blame] | 30 | ; CHECK: risbg [[REGISTER:%r[0-5]]], %r2, 0, 159, 2 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 31 | ; 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. |
| 39 | define float @f4(i64 %big) { |
| 40 | ; CHECK: f4: |
| 41 | ; CHECK-NOT: %r2 |
Richard Sandiford | 84f54a3 | 2013-07-11 08:59:12 +0000 | [diff] [blame] | 42 | ; CHECK: risbg [[REG:%r[0-5]]], %r2, 0, 159, 0 |
| 43 | ; CHECK-NOT: [[REG]] |
| 44 | ; CHECK: ldgr %f0, [[REG]] |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 45 | %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. |
| 52 | define 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 Sandiford | 9784649 | 2013-07-09 09:46:39 +0000 | [diff] [blame] | 61 | ; FIXME: it would be better to use one MVC here. |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 62 | define void @f6(fp128 *%a, i128 *%b) { |
| 63 | ; CHECK: f6: |
| 64 | ; CHECK: lg |
Richard Sandiford | 9784649 | 2013-07-09 09:46:39 +0000 | [diff] [blame] | 65 | ; CHECK: mvc |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 66 | ; CHECK: stg |
Richard Sandiford | 9784649 | 2013-07-09 09:46:39 +0000 | [diff] [blame] | 67 | ; CHECK: br %r14 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 68 | %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. |
| 76 | define 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. |
| 85 | define 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. |
| 93 | define 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 | |