Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 1 | ; Test ANDs of a constant into a byte of memory. |
| 2 | ; |
| 3 | ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s |
| 4 | |
| 5 | ; Check the lowest useful constant, expressed as a signed integer. |
| 6 | define void @f1(i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 7 | ; CHECK-LABEL: f1: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 8 | ; CHECK: ni 0(%r2), 1 |
| 9 | ; CHECK: br %r14 |
| 10 | %val = load i8 *%ptr |
| 11 | %and = and i8 %val, -255 |
| 12 | store i8 %and, i8 *%ptr |
| 13 | ret void |
| 14 | } |
| 15 | |
| 16 | ; Check the highest useful constant, expressed as a signed integer. |
| 17 | define void @f2(i8 *%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: ni 0(%r2), 254 |
| 20 | ; CHECK: br %r14 |
| 21 | %val = load i8 *%ptr |
| 22 | %and = and i8 %val, -2 |
| 23 | store i8 %and, i8 *%ptr |
| 24 | ret void |
| 25 | } |
| 26 | |
| 27 | ; Check the lowest useful constant, expressed as an unsigned integer. |
| 28 | define void @f3(i8 *%ptr) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 29 | ; CHECK-LABEL: f3: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 30 | ; CHECK: ni 0(%r2), 1 |
| 31 | ; CHECK: br %r14 |
| 32 | %val = load i8 *%ptr |
| 33 | %and = and i8 %val, 1 |
| 34 | store i8 %and, i8 *%ptr |
| 35 | ret void |
| 36 | } |
| 37 | |
| 38 | ; Check the highest useful constant, expressed as a unsigned integer. |
| 39 | define void @f4(i8 *%ptr) { |
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: ni 0(%r2), 254 |
| 42 | ; CHECK: br %r14 |
| 43 | %val = load i8 *%ptr |
| 44 | %and = and i8 %val, 254 |
| 45 | store i8 %and, i8 *%ptr |
| 46 | ret void |
| 47 | } |
| 48 | |
| 49 | ; Check the high end of the NI range. |
| 50 | define void @f5(i8 *%src) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 51 | ; CHECK-LABEL: f5: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 52 | ; CHECK: ni 4095(%r2), 127 |
| 53 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame^] | 54 | %ptr = getelementptr i8, i8 *%src, i64 4095 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 55 | %val = load i8 *%ptr |
| 56 | %and = and i8 %val, 127 |
| 57 | store i8 %and, i8 *%ptr |
| 58 | ret void |
| 59 | } |
| 60 | |
| 61 | ; Check the next byte up, which should use NIY instead of NI. |
| 62 | define void @f6(i8 *%src) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 63 | ; CHECK-LABEL: f6: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 64 | ; CHECK: niy 4096(%r2), 127 |
| 65 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame^] | 66 | %ptr = getelementptr i8, i8 *%src, i64 4096 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 67 | %val = load i8 *%ptr |
| 68 | %and = and i8 %val, 127 |
| 69 | store i8 %and, i8 *%ptr |
| 70 | ret void |
| 71 | } |
| 72 | |
| 73 | ; Check the high end of the NIY range. |
| 74 | define void @f7(i8 *%src) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 75 | ; CHECK-LABEL: f7: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 76 | ; CHECK: niy 524287(%r2), 127 |
| 77 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame^] | 78 | %ptr = getelementptr i8, i8 *%src, i64 524287 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 79 | %val = load i8 *%ptr |
| 80 | %and = and i8 %val, 127 |
| 81 | store i8 %and, i8 *%ptr |
| 82 | ret void |
| 83 | } |
| 84 | |
| 85 | ; Check the next byte up, which needs separate address logic. |
| 86 | ; Other sequences besides this one would be OK. |
| 87 | define void @f8(i8 *%src) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 88 | ; CHECK-LABEL: f8: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 89 | ; CHECK: agfi %r2, 524288 |
| 90 | ; CHECK: ni 0(%r2), 127 |
| 91 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame^] | 92 | %ptr = getelementptr i8, i8 *%src, i64 524288 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 93 | %val = load i8 *%ptr |
| 94 | %and = and i8 %val, 127 |
| 95 | store i8 %and, i8 *%ptr |
| 96 | ret void |
| 97 | } |
| 98 | |
| 99 | ; Check the high end of the negative NIY range. |
| 100 | define void @f9(i8 *%src) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 101 | ; CHECK-LABEL: f9: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 102 | ; CHECK: niy -1(%r2), 127 |
| 103 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame^] | 104 | %ptr = getelementptr i8, i8 *%src, i64 -1 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 105 | %val = load i8 *%ptr |
| 106 | %and = and i8 %val, 127 |
| 107 | store i8 %and, i8 *%ptr |
| 108 | ret void |
| 109 | } |
| 110 | |
| 111 | ; Check the low end of the NIY range. |
| 112 | define void @f10(i8 *%src) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 113 | ; CHECK-LABEL: f10: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 114 | ; CHECK: niy -524288(%r2), 127 |
| 115 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame^] | 116 | %ptr = getelementptr i8, i8 *%src, i64 -524288 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 117 | %val = load i8 *%ptr |
| 118 | %and = and i8 %val, 127 |
| 119 | store i8 %and, i8 *%ptr |
| 120 | ret void |
| 121 | } |
| 122 | |
| 123 | ; Check the next byte down, which needs separate address logic. |
| 124 | ; Other sequences besides this one would be OK. |
| 125 | define void @f11(i8 *%src) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 126 | ; CHECK-LABEL: f11: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 127 | ; CHECK: agfi %r2, -524289 |
| 128 | ; CHECK: ni 0(%r2), 127 |
| 129 | ; CHECK: br %r14 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame^] | 130 | %ptr = getelementptr i8, i8 *%src, i64 -524289 |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 131 | %val = load i8 *%ptr |
| 132 | %and = and i8 %val, 127 |
| 133 | store i8 %and, i8 *%ptr |
| 134 | ret void |
| 135 | } |
| 136 | |
| 137 | ; Check that NI does not allow an index |
| 138 | define void @f12(i64 %src, i64 %index) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 139 | ; CHECK-LABEL: f12: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 140 | ; CHECK: agr %r2, %r3 |
| 141 | ; CHECK: ni 4095(%r2), 127 |
| 142 | ; CHECK: br %r14 |
| 143 | %add1 = add i64 %src, %index |
| 144 | %add2 = add i64 %add1, 4095 |
| 145 | %ptr = inttoptr i64 %add2 to i8 * |
| 146 | %val = load i8 *%ptr |
| 147 | %and = and i8 %val, 127 |
| 148 | store i8 %and, i8 *%ptr |
| 149 | ret void |
| 150 | } |
| 151 | |
| 152 | ; Check that NIY does not allow an index |
| 153 | define void @f13(i64 %src, i64 %index) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 154 | ; CHECK-LABEL: f13: |
Ulrich Weigand | 9e3577f | 2013-05-06 16:17:29 +0000 | [diff] [blame] | 155 | ; CHECK: agr %r2, %r3 |
| 156 | ; CHECK: niy 4096(%r2), 127 |
| 157 | ; CHECK: br %r14 |
| 158 | %add1 = add i64 %src, %index |
| 159 | %add2 = add i64 %add1, 4096 |
| 160 | %ptr = inttoptr i64 %add2 to i8 * |
| 161 | %val = load i8 *%ptr |
| 162 | %and = and i8 %val, 127 |
| 163 | store i8 %and, i8 *%ptr |
| 164 | ret void |
| 165 | } |