Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 1 | ; Verify that strict FP operations are not rescheduled |
| 2 | ; |
| 3 | ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s |
| 4 | |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 5 | declare float @llvm.experimental.constrained.sqrt.f32(float, metadata, metadata) |
| 6 | declare float @llvm.sqrt.f32(float) |
| 7 | declare void @llvm.s390.sfpc(i32) |
| 8 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 9 | ; The basic assumption of all following tests is that on z13, we never |
| 10 | ; want to see two square root instructions directly in a row, so the |
| 11 | ; post-RA scheduler will always schedule something else in between |
| 12 | ; whenever possible. |
| 13 | |
| 14 | ; We can move any FP operation across a (normal) store. |
| 15 | |
| 16 | define void @f1(float %f1, float %f2, float *%ptr1, float *%ptr2) { |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 17 | ; CHECK-LABEL: f1: |
| 18 | ; CHECK: sqebr |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 19 | ; CHECK: ste |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 20 | ; CHECK: sqebr |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 21 | ; CHECK: ste |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 22 | ; CHECK: br %r14 |
| 23 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 24 | %sqrt1 = call float @llvm.sqrt.f32(float %f1) |
| 25 | %sqrt2 = call float @llvm.sqrt.f32(float %f2) |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 26 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 27 | store float %sqrt1, float *%ptr1 |
| 28 | store float %sqrt2, float *%ptr2 |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 29 | |
| 30 | ret void |
| 31 | } |
| 32 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 33 | define void @f2(float %f1, float %f2, float *%ptr1, float *%ptr2) { |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 34 | ; CHECK-LABEL: f2: |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 35 | ; CHECK: sqebr |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 36 | ; CHECK: ste |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 37 | ; CHECK: sqebr |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 38 | ; CHECK: ste |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 39 | ; CHECK: br %r14 |
| 40 | |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 41 | %sqrt1 = call float @llvm.experimental.constrained.sqrt.f32( |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 42 | float %f1, |
| 43 | metadata !"round.dynamic", |
| 44 | metadata !"fpexcept.ignore") |
| 45 | %sqrt2 = call float @llvm.experimental.constrained.sqrt.f32( |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 46 | float %f2, |
| 47 | metadata !"round.dynamic", |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 48 | metadata !"fpexcept.ignore") |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 49 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 50 | store float %sqrt1, float *%ptr1 |
| 51 | store float %sqrt2, float *%ptr2 |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 52 | |
| 53 | ret void |
| 54 | } |
| 55 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 56 | define void @f3(float %f1, float %f2, float *%ptr1, float *%ptr2) { |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 57 | ; CHECK-LABEL: f3: |
| 58 | ; CHECK: sqebr |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 59 | ; CHECK: ste |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 60 | ; CHECK: sqebr |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 61 | ; CHECK: ste |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 62 | ; CHECK: br %r14 |
| 63 | |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 64 | %sqrt1 = call float @llvm.experimental.constrained.sqrt.f32( |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 65 | float %f1, |
| 66 | metadata !"round.dynamic", |
| 67 | metadata !"fpexcept.strict") |
| 68 | %sqrt2 = call float @llvm.experimental.constrained.sqrt.f32( |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 69 | float %f2, |
| 70 | metadata !"round.dynamic", |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 71 | metadata !"fpexcept.strict") |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 72 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 73 | store float %sqrt1, float *%ptr1 |
| 74 | store float %sqrt2, float *%ptr2 |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 75 | |
| 76 | ret void |
| 77 | } |
| 78 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 79 | |
| 80 | ; We can move a non-strict FP operation or a fpexcept.ignore |
| 81 | ; operation even across a volatile store, but not a fpexcept.strict |
| 82 | ; operation. |
| 83 | |
| 84 | define void @f4(float %f1, float %f2, float *%ptr1, float *%ptr2) { |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 85 | ; CHECK-LABEL: f4: |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 86 | ; CHECK: sqebr |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 87 | ; CHECK: ste |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 88 | ; CHECK: sqebr |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 89 | ; CHECK: ste |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 90 | ; CHECK: br %r14 |
| 91 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 92 | %sqrt1 = call float @llvm.sqrt.f32(float %f1) |
| 93 | %sqrt2 = call float @llvm.sqrt.f32(float %f2) |
| 94 | |
| 95 | store volatile float %sqrt1, float *%ptr1 |
| 96 | store volatile float %sqrt2, float *%ptr2 |
| 97 | |
| 98 | ret void |
| 99 | } |
| 100 | |
| 101 | define void @f5(float %f1, float %f2, float *%ptr1, float *%ptr2) { |
| 102 | ; CHECK-LABEL: f5: |
| 103 | ; CHECK: sqebr |
| 104 | ; CHECK: ste |
| 105 | ; CHECK: sqebr |
| 106 | ; CHECK: ste |
| 107 | ; CHECK: br %r14 |
| 108 | |
| 109 | %sqrt1 = call float @llvm.experimental.constrained.sqrt.f32( |
| 110 | float %f1, |
| 111 | metadata !"round.dynamic", |
| 112 | metadata !"fpexcept.ignore") |
| 113 | %sqrt2 = call float @llvm.experimental.constrained.sqrt.f32( |
| 114 | float %f2, |
| 115 | metadata !"round.dynamic", |
| 116 | metadata !"fpexcept.ignore") |
| 117 | |
| 118 | store volatile float %sqrt1, float *%ptr1 |
| 119 | store volatile float %sqrt2, float *%ptr2 |
| 120 | |
| 121 | ret void |
| 122 | } |
| 123 | |
| 124 | define void @f6(float %f1, float %f2, float *%ptr1, float *%ptr2) { |
| 125 | ; CHECK-LABEL: f6: |
| 126 | ; CHECK: sqebr |
| 127 | ; CHECK: sqebr |
| 128 | ; CHECK: ste |
| 129 | ; CHECK: ste |
| 130 | ; CHECK: br %r14 |
| 131 | |
| 132 | %sqrt1 = call float @llvm.experimental.constrained.sqrt.f32( |
| 133 | float %f1, |
| 134 | metadata !"round.dynamic", |
| 135 | metadata !"fpexcept.strict") |
| 136 | %sqrt2 = call float @llvm.experimental.constrained.sqrt.f32( |
| 137 | float %f2, |
| 138 | metadata !"round.dynamic", |
| 139 | metadata !"fpexcept.strict") |
| 140 | |
| 141 | store volatile float %sqrt1, float *%ptr1 |
| 142 | store volatile float %sqrt2, float *%ptr2 |
| 143 | |
| 144 | ret void |
| 145 | } |
| 146 | |
| 147 | |
| 148 | ; No variant of FP operations can be scheduled across a SPFC. |
| 149 | |
| 150 | define void @f7(float %f1, float %f2, float *%ptr1, float *%ptr2) { |
| 151 | ; CHECK-LABEL: f7: |
| 152 | ; CHECK: sqebr |
| 153 | ; CHECK: sqebr |
| 154 | ; CHECK: ste |
| 155 | ; CHECK: ste |
| 156 | ; CHECK: br %r14 |
| 157 | |
| 158 | %sqrt1 = call float @llvm.sqrt.f32(float %f1) |
| 159 | %sqrt2 = call float @llvm.sqrt.f32(float %f2) |
| 160 | |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 161 | call void @llvm.s390.sfpc(i32 0) |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 162 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 163 | store float %sqrt1, float *%ptr1 |
| 164 | store float %sqrt2, float *%ptr2 |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 165 | |
Ulrich Weigand | 450c62e | 2019-07-16 15:55:45 +0000 | [diff] [blame^] | 166 | ret void |
| 167 | } |
| 168 | |
| 169 | define void @f8(float %f1, float %f2, float *%ptr1, float *%ptr2) { |
| 170 | ; CHECK-LABEL: f8: |
| 171 | ; CHECK: sqebr |
| 172 | ; CHECK: sqebr |
| 173 | ; CHECK: ste |
| 174 | ; CHECK: ste |
| 175 | ; CHECK: br %r14 |
| 176 | |
| 177 | %sqrt1 = call float @llvm.experimental.constrained.sqrt.f32( |
| 178 | float %f1, |
| 179 | metadata !"round.dynamic", |
| 180 | metadata !"fpexcept.ignore") |
| 181 | %sqrt2 = call float @llvm.experimental.constrained.sqrt.f32( |
| 182 | float %f2, |
| 183 | metadata !"round.dynamic", |
| 184 | metadata !"fpexcept.ignore") |
| 185 | |
| 186 | call void @llvm.s390.sfpc(i32 0) |
| 187 | |
| 188 | store float %sqrt1, float *%ptr1 |
| 189 | store float %sqrt2, float *%ptr2 |
| 190 | |
| 191 | ret void |
| 192 | } |
| 193 | |
| 194 | define void @f9(float %f1, float %f2, float *%ptr1, float *%ptr2) { |
| 195 | ; CHECK-LABEL: f9: |
| 196 | ; CHECK: sqebr |
| 197 | ; CHECK: sqebr |
| 198 | ; CHECK: ste |
| 199 | ; CHECK: ste |
| 200 | ; CHECK: br %r14 |
| 201 | |
| 202 | %sqrt1 = call float @llvm.experimental.constrained.sqrt.f32( |
| 203 | float %f1, |
| 204 | metadata !"round.dynamic", |
| 205 | metadata !"fpexcept.strict") |
| 206 | %sqrt2 = call float @llvm.experimental.constrained.sqrt.f32( |
| 207 | float %f2, |
| 208 | metadata !"round.dynamic", |
| 209 | metadata !"fpexcept.strict") |
| 210 | |
| 211 | call void @llvm.s390.sfpc(i32 0) |
| 212 | |
| 213 | store float %sqrt1, float *%ptr1 |
| 214 | store float %sqrt2, float *%ptr2 |
Ulrich Weigand | 6c5d5ce | 2019-06-05 22:33:10 +0000 | [diff] [blame] | 215 | |
| 216 | ret void |
| 217 | } |
| 218 | |