|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt < %s -passes=instcombine -S | FileCheck %s |
| 3 | + |
| 4 | +define i1 @vec_reduce_umax_non_zero(<4 x i8> %xx) { |
| 5 | +; CHECK-LABEL: @vec_reduce_umax_non_zero( |
| 6 | +; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 0, i8 1, i8 0, i8 0> |
| 7 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umax.v4i8(<4 x i8> [[X]]) |
| 8 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 9 | +; CHECK-NEXT: ret i1 [[R]] |
| 10 | +; |
| 11 | + %x = add nuw <4 x i8> %xx, <i8 0, i8 1, i8 0, i8 0> |
| 12 | + %v = call i8 @llvm.vector.reduce.umax(<4 x i8> %x) |
| 13 | + %r = icmp eq i8 %v, 0 |
| 14 | + ret i1 %r |
| 15 | +} |
| 16 | + |
| 17 | +define i1 @vec_reduce_umax_non_zero_fail(<4 x i8> %xx) { |
| 18 | +; CHECK-LABEL: @vec_reduce_umax_non_zero_fail( |
| 19 | +; CHECK-NEXT: [[X:%.*]] = add nsw <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 1> |
| 20 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umax.v4i8(<4 x i8> [[X]]) |
| 21 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 22 | +; CHECK-NEXT: ret i1 [[R]] |
| 23 | +; |
| 24 | + %x = add nsw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1> |
| 25 | + %v = call i8 @llvm.vector.reduce.umax(<4 x i8> %x) |
| 26 | + %r = icmp eq i8 %v, 0 |
| 27 | + ret i1 %r |
| 28 | +} |
| 29 | + |
| 30 | +define i1 @vec_reduce_umin_non_zero(<4 x i8> %xx) { |
| 31 | +; CHECK-LABEL: @vec_reduce_umin_non_zero( |
| 32 | +; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 1> |
| 33 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umin.v4i8(<4 x i8> [[X]]) |
| 34 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 35 | +; CHECK-NEXT: ret i1 [[R]] |
| 36 | +; |
| 37 | + %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1> |
| 38 | + %v = call i8 @llvm.vector.reduce.umin(<4 x i8> %x) |
| 39 | + %r = icmp eq i8 %v, 0 |
| 40 | + ret i1 %r |
| 41 | +} |
| 42 | + |
| 43 | +define i1 @vec_reduce_umin_non_zero_fail(<4 x i8> %xx) { |
| 44 | +; CHECK-LABEL: @vec_reduce_umin_non_zero_fail( |
| 45 | +; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 0, i8 1, i8 1, i8 1> |
| 46 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umin.v4i8(<4 x i8> [[X]]) |
| 47 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 48 | +; CHECK-NEXT: ret i1 [[R]] |
| 49 | +; |
| 50 | + %x = add nuw <4 x i8> %xx, <i8 0, i8 1, i8 1, i8 1> |
| 51 | + %v = call i8 @llvm.vector.reduce.umin(<4 x i8> %x) |
| 52 | + %r = icmp eq i8 %v, 0 |
| 53 | + ret i1 %r |
| 54 | +} |
| 55 | + |
| 56 | +define i1 @vec_reduce_smax_non_zero0(<4 x i8> %xx) { |
| 57 | +; CHECK-LABEL: @vec_reduce_smax_non_zero0( |
| 58 | +; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 1> |
| 59 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.smax.v4i8(<4 x i8> [[X]]) |
| 60 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 61 | +; CHECK-NEXT: ret i1 [[R]] |
| 62 | +; |
| 63 | + %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1> |
| 64 | + %v = call i8 @llvm.vector.reduce.smax(<4 x i8> %x) |
| 65 | + %r = icmp eq i8 %v, 0 |
| 66 | + ret i1 %r |
| 67 | +} |
| 68 | + |
| 69 | +define i1 @vec_reduce_smax_non_zero1(<4 x i8> %xx) { |
| 70 | +; CHECK-LABEL: @vec_reduce_smax_non_zero1( |
| 71 | +; CHECK-NEXT: [[X0:%.*]] = and <4 x i8> [[XX:%.*]], <i8 127, i8 -1, i8 -1, i8 -1> |
| 72 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[X0]], <i8 1, i8 0, i8 0, i8 0> |
| 73 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.smax.v4i8(<4 x i8> [[X]]) |
| 74 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 75 | +; CHECK-NEXT: ret i1 [[R]] |
| 76 | +; |
| 77 | + %x0 = and <4 x i8> %xx, <i8 127, i8 255, i8 255, i8 255> |
| 78 | + %x = or <4 x i8> %x0, <i8 1, i8 0, i8 0, i8 0> |
| 79 | + %v = call i8 @llvm.vector.reduce.smax(<4 x i8> %x) |
| 80 | + %r = icmp eq i8 %v, 0 |
| 81 | + ret i1 %r |
| 82 | +} |
| 83 | + |
| 84 | +define i1 @vec_reduce_smax_non_zero_fail(<4 x i8> %xx) { |
| 85 | +; CHECK-LABEL: @vec_reduce_smax_non_zero_fail( |
| 86 | +; CHECK-NEXT: [[X0:%.*]] = and <4 x i8> [[XX:%.*]], <i8 127, i8 -1, i8 -1, i8 -1> |
| 87 | +; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[X0]], <i8 1, i8 0, i8 0, i8 0> |
| 88 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.smax.v4i8(<4 x i8> [[X]]) |
| 89 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 90 | +; CHECK-NEXT: ret i1 [[R]] |
| 91 | +; |
| 92 | + %x0 = and <4 x i8> %xx, <i8 127, i8 255, i8 255, i8 255> |
| 93 | + %x = add nuw <4 x i8> %x0, <i8 1, i8 0, i8 0, i8 0> |
| 94 | + %v = call i8 @llvm.vector.reduce.smax(<4 x i8> %x) |
| 95 | + %r = icmp eq i8 %v, 0 |
| 96 | + ret i1 %r |
| 97 | +} |
| 98 | + |
| 99 | +define i1 @vec_reduce_smin_non_zero0(<4 x i8> %xx) { |
| 100 | +; CHECK-LABEL: @vec_reduce_smin_non_zero0( |
| 101 | +; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 1> |
| 102 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.smin.v4i8(<4 x i8> [[X]]) |
| 103 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 104 | +; CHECK-NEXT: ret i1 [[R]] |
| 105 | +; |
| 106 | + %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1> |
| 107 | + %v = call i8 @llvm.vector.reduce.smin(<4 x i8> %x) |
| 108 | + %r = icmp eq i8 %v, 0 |
| 109 | + ret i1 %r |
| 110 | +} |
| 111 | + |
| 112 | +define i1 @vec_reduce_smin_non_zero1(<4 x i8> %xx) { |
| 113 | +; CHECK-LABEL: @vec_reduce_smin_non_zero1( |
| 114 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 0, i8 0, i8 0, i8 -128> |
| 115 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.smin.v4i8(<4 x i8> [[X]]) |
| 116 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 117 | +; CHECK-NEXT: ret i1 [[R]] |
| 118 | +; |
| 119 | + %x = or <4 x i8> %xx, <i8 0, i8 0, i8 0, i8 128> |
| 120 | + %v = call i8 @llvm.vector.reduce.smin(<4 x i8> %x) |
| 121 | + %r = icmp eq i8 %v, 0 |
| 122 | + ret i1 %r |
| 123 | +} |
| 124 | + |
| 125 | +define i1 @vec_reduce_smin_non_zero_fail(<4 x i8> %xx) { |
| 126 | +; CHECK-LABEL: @vec_reduce_smin_non_zero_fail( |
| 127 | +; CHECK-NEXT: [[X0:%.*]] = or <4 x i8> [[XX:%.*]], <i8 0, i8 0, i8 0, i8 -128> |
| 128 | +; CHECK-NEXT: [[X:%.*]] = add <4 x i8> [[X0]], <i8 0, i8 0, i8 0, i8 1> |
| 129 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.smin.v4i8(<4 x i8> [[X]]) |
| 130 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 |
| 131 | +; CHECK-NEXT: ret i1 [[R]] |
| 132 | +; |
| 133 | + %x0 = or <4 x i8> %xx, <i8 0, i8 0, i8 0, i8 128> |
| 134 | + %x = add <4 x i8> %x0, <i8 0, i8 0, i8 0, i8 1> |
| 135 | + %v = call i8 @llvm.vector.reduce.smin(<4 x i8> %x) |
| 136 | + %r = icmp eq i8 %v, 0 |
| 137 | + ret i1 %r |
| 138 | +} |
| 139 | + |
| 140 | +define i8 @vec_reduce_umax_known0(<4 x i8> %xx) { |
| 141 | +; CHECK-LABEL: @vec_reduce_umax_known0( |
| 142 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 1> |
| 143 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umax.v4i8(<4 x i8> [[X]]) |
| 144 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1 |
| 145 | +; CHECK-NEXT: ret i8 [[R]] |
| 146 | +; |
| 147 | + %x = or <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1> |
| 148 | + %v = call i8 @llvm.vector.reduce.umax(<4 x i8> %x) |
| 149 | + %r = and i8 %v, 1 |
| 150 | + ret i8 %r |
| 151 | +} |
| 152 | + |
| 153 | +define i8 @vec_reduce_umax_known1(<4 x i8> %xx) { |
| 154 | +; CHECK-LABEL: @vec_reduce_umax_known1( |
| 155 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 -128> |
| 156 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umax.v4i8(<4 x i8> [[X]]) |
| 157 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], -128 |
| 158 | +; CHECK-NEXT: ret i8 [[R]] |
| 159 | +; |
| 160 | + %x = or <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 128> |
| 161 | + %v = call i8 @llvm.vector.reduce.umax(<4 x i8> %x) |
| 162 | + %r = and i8 %v, 128 |
| 163 | + ret i8 %r |
| 164 | +} |
| 165 | + |
| 166 | +define i8 @vec_reduce_umax_known_fail0(<4 x i8> %xx) { |
| 167 | +; CHECK-LABEL: @vec_reduce_umax_known_fail0( |
| 168 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 -128> |
| 169 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umax.v4i8(<4 x i8> [[X]]) |
| 170 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1 |
| 171 | +; CHECK-NEXT: ret i8 [[R]] |
| 172 | +; |
| 173 | + %x = or <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 128> |
| 174 | + %v = call i8 @llvm.vector.reduce.umax(<4 x i8> %x) |
| 175 | + %r = and i8 %v, 1 |
| 176 | + ret i8 %r |
| 177 | +} |
| 178 | + |
| 179 | +define i8 @vec_reduce_umax_known_fail1(<4 x i8> %xx) { |
| 180 | +; CHECK-LABEL: @vec_reduce_umax_known_fail1( |
| 181 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 1, i8 2, i8 4, i8 8> |
| 182 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umax.v4i8(<4 x i8> [[X]]) |
| 183 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1 |
| 184 | +; CHECK-NEXT: ret i8 [[R]] |
| 185 | +; |
| 186 | + %x = or <4 x i8> %xx, <i8 1, i8 2, i8 4, i8 8> |
| 187 | + %v = call i8 @llvm.vector.reduce.umax(<4 x i8> %x) |
| 188 | + %r = and i8 %v, 1 |
| 189 | + ret i8 %r |
| 190 | +} |
| 191 | + |
| 192 | +define i8 @vec_reduce_umin_known0(<4 x i8> %xx) { |
| 193 | +; CHECK-LABEL: @vec_reduce_umin_known0( |
| 194 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 1> |
| 195 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umin.v4i8(<4 x i8> [[X]]) |
| 196 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1 |
| 197 | +; CHECK-NEXT: ret i8 [[R]] |
| 198 | +; |
| 199 | + %x = or <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1> |
| 200 | + %v = call i8 @llvm.vector.reduce.umin(<4 x i8> %x) |
| 201 | + %r = and i8 %v, 1 |
| 202 | + ret i8 %r |
| 203 | +} |
| 204 | + |
| 205 | +define i8 @vec_reduce_umin_known1(<4 x i8> %xx) { |
| 206 | +; CHECK-LABEL: @vec_reduce_umin_known1( |
| 207 | +; CHECK-NEXT: [[X:%.*]] = and <4 x i8> [[XX:%.*]], <i8 127, i8 -1, i8 -1, i8 -1> |
| 208 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umin.v4i8(<4 x i8> [[X]]) |
| 209 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], -128 |
| 210 | +; CHECK-NEXT: ret i8 [[R]] |
| 211 | +; |
| 212 | + %x = and <4 x i8> %xx, <i8 127, i8 255, i8 255, i8 255> |
| 213 | + %v = call i8 @llvm.vector.reduce.umin(<4 x i8> %x) |
| 214 | + %r = and i8 %v, 128 |
| 215 | + ret i8 %r |
| 216 | +} |
| 217 | + |
| 218 | +define i8 @vec_reduce_umin_known_fail0(<4 x i8> %xx) { |
| 219 | +; CHECK-LABEL: @vec_reduce_umin_known_fail0( |
| 220 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 1, i8 0, i8 0, i8 0> |
| 221 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umin.v4i8(<4 x i8> [[X]]) |
| 222 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1 |
| 223 | +; CHECK-NEXT: ret i8 [[R]] |
| 224 | +; |
| 225 | + %x0 = and <4 x i8> %xx, <i8 127, i8 255, i8 255, i8 255> |
| 226 | + %x = or <4 x i8> %xx, <i8 1, i8 0, i8 0, i8 0> |
| 227 | + %v = call i8 @llvm.vector.reduce.umin(<4 x i8> %x) |
| 228 | + %r = and i8 %v, 1 |
| 229 | + ret i8 %r |
| 230 | +} |
| 231 | + |
| 232 | +define i8 @vec_reduce_umin_known_fail1(<4 x i8> %xx) { |
| 233 | +; CHECK-LABEL: @vec_reduce_umin_known_fail1( |
| 234 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 1, i8 2, i8 4, i8 8> |
| 235 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umin.v4i8(<4 x i8> [[X]]) |
| 236 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1 |
| 237 | +; CHECK-NEXT: ret i8 [[R]] |
| 238 | +; |
| 239 | + %x = or <4 x i8> %xx, <i8 1, i8 2, i8 4, i8 8> |
| 240 | + %v = call i8 @llvm.vector.reduce.umin(<4 x i8> %x) |
| 241 | + %r = and i8 %v, 1 |
| 242 | + ret i8 %r |
| 243 | +} |
| 244 | + |
| 245 | +define i8 @vec_reduce_smax_known(<4 x i8> %xx) { |
| 246 | +; CHECK-LABEL: @vec_reduce_smax_known( |
| 247 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 4, i8 4, i8 4, i8 5> |
| 248 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.smax.v4i8(<4 x i8> [[X]]) |
| 249 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 4 |
| 250 | +; CHECK-NEXT: ret i8 [[R]] |
| 251 | +; |
| 252 | + %x = or <4 x i8> %xx, <i8 4, i8 4, i8 4, i8 5> |
| 253 | + %v = call i8 @llvm.vector.reduce.smax(<4 x i8> %x) |
| 254 | + %r = and i8 %v, 4 |
| 255 | + ret i8 %r |
| 256 | +} |
| 257 | + |
| 258 | +define i8 @vec_reduce_smax_known_fail(<4 x i8> %xx) { |
| 259 | +; CHECK-LABEL: @vec_reduce_smax_known_fail( |
| 260 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 4, i8 4, i8 8, i8 5> |
| 261 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.umax.v4i8(<4 x i8> [[X]]) |
| 262 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 4 |
| 263 | +; CHECK-NEXT: ret i8 [[R]] |
| 264 | +; |
| 265 | + %x = or <4 x i8> %xx, <i8 4, i8 4, i8 8, i8 5> |
| 266 | + %v = call i8 @llvm.vector.reduce.umax(<4 x i8> %x) |
| 267 | + %r = and i8 %v, 4 |
| 268 | + ret i8 %r |
| 269 | +} |
| 270 | + |
| 271 | +define i8 @vec_reduce_smin_known(<4 x i8> %xx) { |
| 272 | +; CHECK-LABEL: @vec_reduce_smin_known( |
| 273 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 8, i8 24, i8 56, i8 9> |
| 274 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.smin.v4i8(<4 x i8> [[X]]) |
| 275 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 8 |
| 276 | +; CHECK-NEXT: ret i8 [[R]] |
| 277 | +; |
| 278 | + %x = or <4 x i8> %xx, <i8 8, i8 24, i8 56, i8 9> |
| 279 | + %v = call i8 @llvm.vector.reduce.smin(<4 x i8> %x) |
| 280 | + %r = and i8 %v, 8 |
| 281 | + ret i8 %r |
| 282 | +} |
| 283 | + |
| 284 | +define i8 @vec_reduce_smin_known_fail(<4 x i8> %xx) { |
| 285 | +; CHECK-LABEL: @vec_reduce_smin_known_fail( |
| 286 | +; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 8, i8 23, i8 56, i8 9> |
| 287 | +; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.smin.v4i8(<4 x i8> [[X]]) |
| 288 | +; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 8 |
| 289 | +; CHECK-NEXT: ret i8 [[R]] |
| 290 | +; |
| 291 | + %x = or <4 x i8> %xx, <i8 8, i8 23, i8 56, i8 9> |
| 292 | + %v = call i8 @llvm.vector.reduce.smin(<4 x i8> %x) |
| 293 | + %r = and i8 %v, 8 |
| 294 | + ret i8 %r |
| 295 | +} |
0 commit comments