| Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame^] | 1 | ; Test 32-bit square root. |
| 2 | ; |
| 3 | ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s |
| 4 | |
| 5 | declare float @llvm.sqrt.f32(float %f) |
| 6 | |
| 7 | ; Check register square root. |
| 8 | define float @f1(float %val) { |
| 9 | ; CHECK: f1: |
| 10 | ; CHECK: sqebr %f0, %f0 |
| 11 | ; CHECK: br %r14 |
| 12 | %res = call float @llvm.sqrt.f32(float %val) |
| 13 | ret float %res |
| 14 | } |
| 15 | |
| 16 | ; Check the low end of the SQEB range. |
| 17 | define float @f2(float *%ptr) { |
| 18 | ; CHECK: f2: |
| 19 | ; CHECK: sqeb %f0, 0(%r2) |
| 20 | ; CHECK: br %r14 |
| 21 | %val = load float *%ptr |
| 22 | %res = call float @llvm.sqrt.f32(float %val) |
| 23 | ret float %res |
| 24 | } |
| 25 | |
| 26 | ; Check the high end of the aligned SQEB range. |
| 27 | define float @f3(float *%base) { |
| 28 | ; CHECK: f3: |
| 29 | ; CHECK: sqeb %f0, 4092(%r2) |
| 30 | ; CHECK: br %r14 |
| 31 | %ptr = getelementptr float *%base, i64 1023 |
| 32 | %val = load float *%ptr |
| 33 | %res = call float @llvm.sqrt.f32(float %val) |
| 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 *%base) { |
| 40 | ; CHECK: f4: |
| 41 | ; CHECK: aghi %r2, 4096 |
| 42 | ; CHECK: sqeb %f0, 0(%r2) |
| 43 | ; CHECK: br %r14 |
| 44 | %ptr = getelementptr float *%base, i64 1024 |
| 45 | %val = load float *%ptr |
| 46 | %res = call float @llvm.sqrt.f32(float %val) |
| 47 | ret float %res |
| 48 | } |
| 49 | |
| 50 | ; Check negative displacements, which also need separate address logic. |
| 51 | define float @f5(float *%base) { |
| 52 | ; CHECK: f5: |
| 53 | ; CHECK: aghi %r2, -4 |
| 54 | ; CHECK: sqeb %f0, 0(%r2) |
| 55 | ; CHECK: br %r14 |
| 56 | %ptr = getelementptr float *%base, i64 -1 |
| 57 | %val = load float *%ptr |
| 58 | %res = call float @llvm.sqrt.f32(float %val) |
| 59 | ret float %res |
| 60 | } |
| 61 | |
| 62 | ; Check that SQEB allows indices. |
| 63 | define float @f6(float *%base, i64 %index) { |
| 64 | ; CHECK: f6: |
| 65 | ; CHECK: sllg %r1, %r3, 2 |
| 66 | ; CHECK: sqeb %f0, 400(%r1,%r2) |
| 67 | ; CHECK: br %r14 |
| 68 | %ptr1 = getelementptr float *%base, i64 %index |
| 69 | %ptr2 = getelementptr float *%ptr1, i64 100 |
| 70 | %val = load float *%ptr2 |
| 71 | %res = call float @llvm.sqrt.f32(float %val) |
| 72 | ret float %res |
| 73 | } |