Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 1 | ; Test 32-bit floating-point division. |
| 2 | ; |
| 3 | ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s |
| 4 | |
Richard Sandiford | ed1fab6 | 2013-07-03 10:10:02 +0000 | [diff] [blame] | 5 | declare float @foo() |
| 6 | |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 7 | ; Check register division. |
| 8 | define float @f1(float %f1, float %f2) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 9 | ; CHECK-LABEL: f1: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 10 | ; CHECK: debr %f0, %f2 |
| 11 | ; CHECK: br %r14 |
| 12 | %res = fdiv float %f1, %f2 |
| 13 | ret float %res |
| 14 | } |
| 15 | |
| 16 | ; Check the low end of the DEB range. |
| 17 | define float @f2(float %f1, float *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 18 | ; CHECK-LABEL: f2: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 19 | ; CHECK: deb %f0, 0(%r2) |
| 20 | ; CHECK: br %r14 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 21 | %f2 = load float , float *%ptr |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 22 | %res = fdiv float %f1, %f2 |
| 23 | ret float %res |
| 24 | } |
| 25 | |
| 26 | ; Check the high end of the aligned DEB range. |
| 27 | define float @f3(float %f1, float *%base) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 28 | ; CHECK-LABEL: f3: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 29 | ; CHECK: deb %f0, 4092(%r2) |
| 30 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 31 | %ptr = getelementptr float, float *%base, i64 1023 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 32 | %f2 = load float , float *%ptr |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 33 | %res = fdiv float %f1, %f2 |
| 34 | ret float %res |
| 35 | } |
| 36 | |
| 37 | ; Check the next word up, which needs separate address logic. |
| 38 | ; Other sequences besides this one would be OK. |
| 39 | define float @f4(float %f1, float *%base) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 40 | ; CHECK-LABEL: f4: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 41 | ; CHECK: aghi %r2, 4096 |
| 42 | ; CHECK: deb %f0, 0(%r2) |
| 43 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 44 | %ptr = getelementptr float, float *%base, i64 1024 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 45 | %f2 = load float , float *%ptr |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 46 | %res = fdiv float %f1, %f2 |
| 47 | ret float %res |
| 48 | } |
| 49 | |
| 50 | ; Check negative displacements, which also need separate address logic. |
| 51 | define float @f5(float %f1, float *%base) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 52 | ; CHECK-LABEL: f5: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 53 | ; CHECK: aghi %r2, -4 |
| 54 | ; CHECK: deb %f0, 0(%r2) |
| 55 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 56 | %ptr = getelementptr float, float *%base, i64 -1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 57 | %f2 = load float , float *%ptr |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 58 | %res = fdiv float %f1, %f2 |
| 59 | ret float %res |
| 60 | } |
| 61 | |
| 62 | ; Check that DEB allows indices. |
| 63 | define float @f6(float %f1, float *%base, i64 %index) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 64 | ; CHECK-LABEL: f6: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 65 | ; CHECK: sllg %r1, %r3, 2 |
| 66 | ; CHECK: deb %f0, 400(%r1,%r2) |
| 67 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 68 | %ptr1 = getelementptr float, float *%base, i64 %index |
| 69 | %ptr2 = getelementptr float, float *%ptr1, i64 100 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 70 | %f2 = load float , float *%ptr2 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 71 | %res = fdiv float %f1, %f2 |
| 72 | ret float %res |
| 73 | } |
Richard Sandiford | ed1fab6 | 2013-07-03 10:10:02 +0000 | [diff] [blame] | 74 | |
| 75 | ; Check that divisions of spilled values can use DEB rather than DEBR. |
| 76 | define float @f7(float *%ptr0) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 77 | ; CHECK-LABEL: f7: |
Richard Sandiford | ed1fab6 | 2013-07-03 10:10:02 +0000 | [diff] [blame] | 78 | ; CHECK: brasl %r14, foo@PLT |
| 79 | ; CHECK: deb %f0, 16{{[04]}}(%r15) |
| 80 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 81 | %ptr1 = getelementptr float, float *%ptr0, i64 2 |
| 82 | %ptr2 = getelementptr float, float *%ptr0, i64 4 |
| 83 | %ptr3 = getelementptr float, float *%ptr0, i64 6 |
| 84 | %ptr4 = getelementptr float, float *%ptr0, i64 8 |
| 85 | %ptr5 = getelementptr float, float *%ptr0, i64 10 |
| 86 | %ptr6 = getelementptr float, float *%ptr0, i64 12 |
| 87 | %ptr7 = getelementptr float, float *%ptr0, i64 14 |
| 88 | %ptr8 = getelementptr float, float *%ptr0, i64 16 |
| 89 | %ptr9 = getelementptr float, float *%ptr0, i64 18 |
| 90 | %ptr10 = getelementptr float, float *%ptr0, i64 20 |
Richard Sandiford | ed1fab6 | 2013-07-03 10:10:02 +0000 | [diff] [blame] | 91 | |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 92 | %val0 = load float , float *%ptr0 |
| 93 | %val1 = load float , float *%ptr1 |
| 94 | %val2 = load float , float *%ptr2 |
| 95 | %val3 = load float , float *%ptr3 |
| 96 | %val4 = load float , float *%ptr4 |
| 97 | %val5 = load float , float *%ptr5 |
| 98 | %val6 = load float , float *%ptr6 |
| 99 | %val7 = load float , float *%ptr7 |
| 100 | %val8 = load float , float *%ptr8 |
| 101 | %val9 = load float , float *%ptr9 |
| 102 | %val10 = load float , float *%ptr10 |
Richard Sandiford | ed1fab6 | 2013-07-03 10:10:02 +0000 | [diff] [blame] | 103 | |
| 104 | %ret = call float @foo() |
| 105 | |
| 106 | %div0 = fdiv float %ret, %val0 |
| 107 | %div1 = fdiv float %div0, %val1 |
| 108 | %div2 = fdiv float %div1, %val2 |
| 109 | %div3 = fdiv float %div2, %val3 |
| 110 | %div4 = fdiv float %div3, %val4 |
| 111 | %div5 = fdiv float %div4, %val5 |
| 112 | %div6 = fdiv float %div5, %val6 |
| 113 | %div7 = fdiv float %div6, %val7 |
| 114 | %div8 = fdiv float %div7, %val8 |
| 115 | %div9 = fdiv float %div8, %val9 |
| 116 | %div10 = fdiv float %div9, %val10 |
| 117 | |
| 118 | ret float %div10 |
| 119 | } |