1e0ce8750SNoah Goldstein; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2e0ce8750SNoah Goldstein; RUN: opt -passes=instsimplify < %s -S | FileCheck %s 3e0ce8750SNoah Goldstein 4e0ce8750SNoah Goldsteindeclare void @llvm.assume(i1) 5e0ce8750SNoah Goldsteindeclare i8 @llvm.abs.i8(i8, i1) 6e0ce8750SNoah Goldsteindeclare i8 @llvm.bitreverse.i8(i8) 7e0ce8750SNoah Goldsteindeclare i16 @llvm.bswap.i16(i16) 8e0ce8750SNoah Goldsteindeclare i8 @llvm.ctpop.i8(i8) 9e0ce8750SNoah Goldsteindeclare <2 x i8> @llvm.uadd.sat.2xi8(<2 x i8>, <2 x i8>) 10e0ce8750SNoah Goldsteindeclare i8 @llvm.uadd.sat.i8(i8, i8) 1174157bf6SNoah Goldsteindeclare i8 @llvm.fshr.i8(i8, i8, i8) 1274157bf6SNoah Goldsteindeclare i8 @llvm.fshl.i8(i8, i8, i8) 13f7bf984eSNoah Goldsteindeclare i8 @llvm.ctlz.i8(i8, i1) 14f7bf984eSNoah Goldsteindeclare i8 @llvm.cttz.i8(i8, i1) 15f7bf984eSNoah Goldsteindeclare i8 @llvm.sadd.sat.i8(i8, i8) 16f7bf984eSNoah Goldsteindeclare i8 @llvm.smax.i8(i8, i8) 17f7bf984eSNoah Goldsteindeclare i8 @llvm.smin.i8(i8, i8) 18f7bf984eSNoah Goldsteindeclare i8 @llvm.sshl.sat.i8(i8, i8) 19f7bf984eSNoah Goldsteindeclare i8 @llvm.ssub.sat.i8(i8, i8) 20f7bf984eSNoah Goldsteindeclare i8 @llvm.umax.i8(i8, i8) 21f7bf984eSNoah Goldsteindeclare i8 @llvm.umin.i8(i8, i8) 22f7bf984eSNoah Goldsteindeclare i8 @llvm.ushl.sat.i8(i8, i8) 23f7bf984eSNoah Goldsteindeclare i8 @llvm.usub.sat.i8(i8, i8) 24f7bf984eSNoah Goldsteindeclare float @llvm.maximum.f32(float, float) 25e0ce8750SNoah Goldstein 26e0ce8750SNoah Goldstein;; Throughout use: X > Y || Y == 0 which folds to X > Y iff X known 27e0ce8750SNoah Goldstein;; non-zero. Do this because many of the expressions already have 28e0ce8750SNoah Goldstein;; hardcoded cases for folding Foo(X) == 0 -> X == 0 and we want to 29e0ce8750SNoah Goldstein;; test explicitly that `isKnownNonZero` works. 30e0ce8750SNoah Goldstein 31e0ce8750SNoah Goldsteindefine i1 @check_neg(i8 %x, i8 %y) { 32e0ce8750SNoah Goldstein; CHECK-LABEL: @check_neg( 33e0ce8750SNoah Goldstein; CHECK-NEXT: [[NE:%.*]] = icmp ne i8 [[X:%.*]], 0 34e0ce8750SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[NE]]) 35e0ce8750SNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = sub i8 0, [[X]] 36e0ce8750SNoah Goldstein; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt i8 [[Z]], [[Y:%.*]] 373bd38f66SNoah Goldstein; CHECK-NEXT: ret i1 [[CMP0]] 38e0ce8750SNoah Goldstein; 39e0ce8750SNoah Goldstein %ne = icmp ne i8 %x, 0 40e0ce8750SNoah Goldstein call void @llvm.assume(i1 %ne) 41e0ce8750SNoah Goldstein %z = sub i8 0, %x 42e0ce8750SNoah Goldstein %cmp0 = icmp ugt i8 %z, %y 43e0ce8750SNoah Goldstein %cmp1 = icmp eq i8 %y, 0 44e0ce8750SNoah Goldstein %r = or i1 %cmp0, %cmp1 45e0ce8750SNoah Goldstein ret i1 %r 46e0ce8750SNoah Goldstein} 47e0ce8750SNoah Goldstein 48e0ce8750SNoah Goldsteindefine i1 @check_abs(i8 %x, i8 %y) { 49e0ce8750SNoah Goldstein; CHECK-LABEL: @check_abs( 50e0ce8750SNoah Goldstein; CHECK-NEXT: [[NE:%.*]] = icmp ne i8 [[X:%.*]], 0 51e0ce8750SNoah Goldstein; CHECK-NEXT: br i1 [[NE]], label [[TRUE:%.*]], label [[FALSE:%.*]] 52e0ce8750SNoah Goldstein; CHECK: true: 53e0ce8750SNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = call i8 @llvm.abs.i8(i8 [[X]], i1 true) 54e0ce8750SNoah Goldstein; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt i8 [[Z]], [[Y:%.*]] 553bd38f66SNoah Goldstein; CHECK-NEXT: ret i1 [[CMP0]] 56e0ce8750SNoah Goldstein; CHECK: false: 57e0ce8750SNoah Goldstein; CHECK-NEXT: ret i1 [[NE]] 58e0ce8750SNoah Goldstein; 59e0ce8750SNoah Goldstein %ne = icmp ne i8 %x, 0 60e0ce8750SNoah Goldstein br i1 %ne, label %true, label %false 61e0ce8750SNoah Goldsteintrue: 62e0ce8750SNoah Goldstein %z = call i8 @llvm.abs.i8(i8 %x, i1 true) 63e0ce8750SNoah Goldstein %cmp0 = icmp ugt i8 %z, %y 64e0ce8750SNoah Goldstein %cmp1 = icmp eq i8 %y, 0 65e0ce8750SNoah Goldstein %r = or i1 %cmp0, %cmp1 66e0ce8750SNoah Goldstein ret i1 %r 67e0ce8750SNoah Goldsteinfalse: 68e0ce8750SNoah Goldstein ret i1 %ne 69e0ce8750SNoah Goldstein} 70e0ce8750SNoah Goldstein 71e0ce8750SNoah Goldsteindefine i1 @check_abs_failish(i8 %x, i8 %y) { 72e0ce8750SNoah Goldstein; CHECK-LABEL: @check_abs_failish( 73e0ce8750SNoah Goldstein; CHECK-NEXT: [[NE:%.*]] = icmp ne i8 [[X:%.*]], 0 74e0ce8750SNoah Goldstein; CHECK-NEXT: br i1 [[NE]], label [[TRUE:%.*]], label [[FALSE:%.*]] 75e0ce8750SNoah Goldstein; CHECK: false: 76e0ce8750SNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = call i8 @llvm.abs.i8(i8 [[X]], i1 true) 77e0ce8750SNoah Goldstein; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt i8 [[Z]], [[Y:%.*]] 78e0ce8750SNoah Goldstein; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[Y]], 0 79e0ce8750SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP0]], [[CMP1]] 80e0ce8750SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 81e0ce8750SNoah Goldstein; CHECK: true: 82e0ce8750SNoah Goldstein; CHECK-NEXT: ret i1 [[NE]] 83e0ce8750SNoah Goldstein; 84e0ce8750SNoah Goldstein %ne = icmp ne i8 %x, 0 85e0ce8750SNoah Goldstein br i1 %ne, label %true, label %false 86e0ce8750SNoah Goldsteinfalse: 87e0ce8750SNoah Goldstein %z = call i8 @llvm.abs.i8(i8 %x, i1 true) 88e0ce8750SNoah Goldstein %cmp0 = icmp ugt i8 %z, %y 89e0ce8750SNoah Goldstein %cmp1 = icmp eq i8 %y, 0 90e0ce8750SNoah Goldstein %r = or i1 %cmp0, %cmp1 91e0ce8750SNoah Goldstein ret i1 %r 92e0ce8750SNoah Goldsteintrue: 93e0ce8750SNoah Goldstein ret i1 %ne 94e0ce8750SNoah Goldstein} 95e0ce8750SNoah Goldstein 96e0ce8750SNoah Goldsteindefine i1 @check_bitreverse(i8 %x, i8 %y) { 97e0ce8750SNoah Goldstein; CHECK-LABEL: @check_bitreverse( 98e0ce8750SNoah Goldstein; CHECK-NEXT: [[NE:%.*]] = icmp ne i8 [[X:%.*]], 0 99e0ce8750SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[NE]]) 100e0ce8750SNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = call i8 @llvm.bitreverse.i8(i8 [[X]]) 101e0ce8750SNoah Goldstein; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt i8 [[Z]], [[Y:%.*]] 1023bd38f66SNoah Goldstein; CHECK-NEXT: ret i1 [[CMP0]] 103e0ce8750SNoah Goldstein; 104e0ce8750SNoah Goldstein %ne = icmp ne i8 %x, 0 105e0ce8750SNoah Goldstein call void @llvm.assume(i1 %ne) 106e0ce8750SNoah Goldstein %z = call i8 @llvm.bitreverse.i8(i8 %x) 107e0ce8750SNoah Goldstein %cmp0 = icmp ugt i8 %z, %y 108e0ce8750SNoah Goldstein %cmp1 = icmp eq i8 %y, 0 109e0ce8750SNoah Goldstein %r = or i1 %cmp0, %cmp1 110e0ce8750SNoah Goldstein ret i1 %r 111e0ce8750SNoah Goldstein} 112e0ce8750SNoah Goldstein 113e0ce8750SNoah Goldsteindefine i1 @check_bswap(i16 %x, i16 %y) { 114e0ce8750SNoah Goldstein; CHECK-LABEL: @check_bswap( 115e0ce8750SNoah Goldstein; CHECK-NEXT: [[NE:%.*]] = icmp ne i16 [[X:%.*]], 0 116e0ce8750SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[NE]]) 117e0ce8750SNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = call i16 @llvm.bswap.i16(i16 [[X]]) 118e0ce8750SNoah Goldstein; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt i16 [[Z]], [[Y:%.*]] 1193bd38f66SNoah Goldstein; CHECK-NEXT: ret i1 [[CMP0]] 120e0ce8750SNoah Goldstein; 121e0ce8750SNoah Goldstein %ne = icmp ne i16 %x, 0 122e0ce8750SNoah Goldstein call void @llvm.assume(i1 %ne) 123e0ce8750SNoah Goldstein %z = call i16 @llvm.bswap.i16(i16 %x) 124e0ce8750SNoah Goldstein %cmp0 = icmp ugt i16 %z, %y 125e0ce8750SNoah Goldstein %cmp1 = icmp eq i16 %y, 0 126e0ce8750SNoah Goldstein %r = or i1 %cmp0, %cmp1 127e0ce8750SNoah Goldstein ret i1 %r 128e0ce8750SNoah Goldstein} 129e0ce8750SNoah Goldstein 130e0ce8750SNoah Goldsteindefine i1 @check_ctpop(i8 %x, i8 %y) { 131e0ce8750SNoah Goldstein; CHECK-LABEL: @check_ctpop( 132e0ce8750SNoah Goldstein; CHECK-NEXT: [[NE:%.*]] = icmp eq i8 [[X:%.*]], 0 133e0ce8750SNoah Goldstein; CHECK-NEXT: br i1 [[NE]], label [[TRUE:%.*]], label [[FALSE:%.*]] 134e0ce8750SNoah Goldstein; CHECK: true: 135e0ce8750SNoah Goldstein; CHECK-NEXT: ret i1 [[NE]] 136e0ce8750SNoah Goldstein; CHECK: false: 137e0ce8750SNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = call i8 @llvm.ctpop.i8(i8 [[X]]) 138e0ce8750SNoah Goldstein; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt i8 [[Z]], [[Y:%.*]] 1393bd38f66SNoah Goldstein; CHECK-NEXT: ret i1 [[CMP0]] 140e0ce8750SNoah Goldstein; 141e0ce8750SNoah Goldstein %ne = icmp eq i8 %x, 0 142e0ce8750SNoah Goldstein br i1 %ne, label %true, label %false 143e0ce8750SNoah Goldsteintrue: 144e0ce8750SNoah Goldstein ret i1 %ne 145e0ce8750SNoah Goldsteinfalse: 146e0ce8750SNoah Goldstein %z = call i8 @llvm.ctpop.i8(i8 %x) 147e0ce8750SNoah Goldstein %cmp0 = icmp ugt i8 %z, %y 148e0ce8750SNoah Goldstein %cmp1 = icmp eq i8 %y, 0 149e0ce8750SNoah Goldstein %r = or i1 %cmp0, %cmp1 150e0ce8750SNoah Goldstein ret i1 %r 151e0ce8750SNoah Goldstein} 152e0ce8750SNoah Goldstein 153e0ce8750SNoah Goldsteindefine i1 @check_add_sat(i8 %x, i8 %y, i8 %w) { 154e0ce8750SNoah Goldstein; CHECK-LABEL: @check_add_sat( 155e0ce8750SNoah Goldstein; CHECK-NEXT: [[NE:%.*]] = icmp ne i8 [[X:%.*]], 0 156e0ce8750SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[NE]]) 157e0ce8750SNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[X]], i8 [[Y:%.*]]) 158e0ce8750SNoah Goldstein; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt i8 [[Z]], [[W:%.*]] 1593bd38f66SNoah Goldstein; CHECK-NEXT: ret i1 [[CMP0]] 160e0ce8750SNoah Goldstein; 161e0ce8750SNoah Goldstein %ne = icmp ne i8 %x, 0 162e0ce8750SNoah Goldstein call void @llvm.assume(i1 %ne) 163e0ce8750SNoah Goldstein %z = call i8 @llvm.uadd.sat.i8(i8 %x, i8 %y) 164e0ce8750SNoah Goldstein %cmp0 = icmp ugt i8 %z, %w 165e0ce8750SNoah Goldstein %cmp1 = icmp eq i8 %w, 0 166e0ce8750SNoah Goldstein %r = or i1 %cmp0, %cmp1 167e0ce8750SNoah Goldstein ret i1 %r 168e0ce8750SNoah Goldstein} 169e0ce8750SNoah Goldstein 170e0ce8750SNoah Goldsteindefine <2 x i1> @check_add_sat_vec(<2 x i8> %x, <2 x i8> %y, <2 x i8> %w) { 171e0ce8750SNoah Goldstein; CHECK-LABEL: @check_add_sat_vec( 172e0ce8750SNoah Goldstein; CHECK-NEXT: [[YNZ:%.*]] = or <2 x i8> [[Y:%.*]], <i8 2, i8 1> 173e0ce8750SNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> [[X:%.*]], <2 x i8> [[YNZ]]) 174e0ce8750SNoah Goldstein; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt <2 x i8> [[Z]], [[W:%.*]] 1753bd38f66SNoah Goldstein; CHECK-NEXT: ret <2 x i1> [[CMP0]] 176e0ce8750SNoah Goldstein; 177e0ce8750SNoah Goldstein %ynz = or <2 x i8> %y, <i8 2, i8 1> 178e0ce8750SNoah Goldstein %z = call <2 x i8> @llvm.uadd.sat.2xi8(<2 x i8> %x, <2 x i8> %ynz) 179e0ce8750SNoah Goldstein %cmp0 = icmp ugt <2 x i8> %z, %w 180e0ce8750SNoah Goldstein %cmp1 = icmp eq <2 x i8> %w, <i8 0, i8 0> 181e0ce8750SNoah Goldstein %r = or <2 x i1> %cmp0, %cmp1 182e0ce8750SNoah Goldstein ret <2 x i1> %r 183e0ce8750SNoah Goldstein} 184e7999fb4SNoah Goldstein 185e7999fb4SNoah Goldsteindefine <2 x i1> @shl_nz_bounded_cnt_vec(<2 x i32> %x, <2 x i32> %y) { 186e7999fb4SNoah Goldstein; CHECK-LABEL: @shl_nz_bounded_cnt_vec( 187684963b8SNoah Goldstein; CHECK-NEXT: ret <2 x i1> zeroinitializer 188e7999fb4SNoah Goldstein; 189e7999fb4SNoah Goldstein %cnt = and <2 x i32> %x, <i32 16, i32 24> 190e7999fb4SNoah Goldstein %val = or <2 x i32> %y, <i32 131088, i32 16> 191e7999fb4SNoah Goldstein %shl = shl <2 x i32> %val, %cnt 192e7999fb4SNoah Goldstein %r = icmp eq <2 x i32> %shl, zeroinitializer 193e7999fb4SNoah Goldstein ret <2 x i1> %r 194e7999fb4SNoah Goldstein} 195e7999fb4SNoah Goldstein 196e7999fb4SNoah Goldsteindefine i1 @shl_nz_bounded_cnt(i32 %cnt, i32 %y) { 197e7999fb4SNoah Goldstein; CHECK-LABEL: @shl_nz_bounded_cnt( 198e7999fb4SNoah Goldstein; CHECK-NEXT: [[CNT_ULT4:%.*]] = icmp ult i32 [[CNT:%.*]], 4 199e7999fb4SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[CNT_ULT4]]) 200684963b8SNoah Goldstein; CHECK-NEXT: ret i1 false 201e7999fb4SNoah Goldstein; 202e7999fb4SNoah Goldstein %cnt_ult4 = icmp ult i32 %cnt, 4 203e7999fb4SNoah Goldstein call void @llvm.assume(i1 %cnt_ult4) 204e7999fb4SNoah Goldstein %val = or i32 %y, 131072 205e7999fb4SNoah Goldstein %shl = shl i32 %val, %cnt 206e7999fb4SNoah Goldstein %r = icmp eq i32 %shl, 0 207e7999fb4SNoah Goldstein ret i1 %r 208e7999fb4SNoah Goldstein} 209e7999fb4SNoah Goldstein 210e7999fb4SNoah Goldsteindefine <2 x i1> @shl_nz_bounded_cnt_vec_todo_no_common_bit(<2 x i32> %x, <2 x i32> %y) { 211e7999fb4SNoah Goldstein; CHECK-LABEL: @shl_nz_bounded_cnt_vec_todo_no_common_bit( 212e7999fb4SNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and <2 x i32> [[X:%.*]], <i32 16, i32 32> 213*38fffa63SPaul Walker; CHECK-NEXT: [[VAL:%.*]] = or <2 x i32> [[Y:%.*]], splat (i32 16) 214e7999fb4SNoah Goldstein; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i32> [[VAL]], [[CNT]] 215e7999fb4SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i32> [[SHL]], zeroinitializer 216e7999fb4SNoah Goldstein; CHECK-NEXT: ret <2 x i1> [[R]] 217e7999fb4SNoah Goldstein; 218e7999fb4SNoah Goldstein %cnt = and <2 x i32> %x, <i32 16, i32 32> 219e7999fb4SNoah Goldstein %val = or <2 x i32> %y, <i32 16, i32 16> 220e7999fb4SNoah Goldstein %shl = shl <2 x i32> %val, %cnt 221e7999fb4SNoah Goldstein %r = icmp eq <2 x i32> %shl, zeroinitializer 222e7999fb4SNoah Goldstein ret <2 x i1> %r 223e7999fb4SNoah Goldstein} 224e7999fb4SNoah Goldstein 225e7999fb4SNoah Goldsteindefine i1 @shl_maybe_zero_bounded_cnt_fail(i32 %x, i32 %y) { 226e7999fb4SNoah Goldstein; CHECK-LABEL: @shl_maybe_zero_bounded_cnt_fail( 227e7999fb4SNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i32 [[X:%.*]], 16 228e7999fb4SNoah Goldstein; CHECK-NEXT: [[VAL:%.*]] = or i32 [[Y:%.*]], 65536 229e7999fb4SNoah Goldstein; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[VAL]], [[CNT]] 230e7999fb4SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[SHL]], 0 231e7999fb4SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 232e7999fb4SNoah Goldstein; 233e7999fb4SNoah Goldstein %cnt = and i32 %x, 16 234e7999fb4SNoah Goldstein %val = or i32 %y, 65536 235e7999fb4SNoah Goldstein %shl = shl i32 %val, %cnt 236e7999fb4SNoah Goldstein %r = icmp eq i32 %shl, 0 237e7999fb4SNoah Goldstein ret i1 %r 238e7999fb4SNoah Goldstein} 239e7999fb4SNoah Goldstein 240e7999fb4SNoah Goldsteindefine i1 @shl_non_zero_nsw(i8 %s, i8 %cnt) { 241e7999fb4SNoah Goldstein; CHECK-LABEL: @shl_non_zero_nsw( 242e7999fb4SNoah Goldstein; CHECK-NEXT: [[NZ:%.*]] = icmp ne i8 [[S:%.*]], 0 243e7999fb4SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[NZ]]) 244f688d215SNoah Goldstein; CHECK-NEXT: ret i1 false 245e7999fb4SNoah Goldstein; 246e7999fb4SNoah Goldstein %nz = icmp ne i8 %s, 0 247e7999fb4SNoah Goldstein call void @llvm.assume(i1 %nz) 248e7999fb4SNoah Goldstein %v = shl nsw i8 %s, %cnt 249e7999fb4SNoah Goldstein %r = icmp eq i8 %v, 0 250e7999fb4SNoah Goldstein ret i1 %r 251e7999fb4SNoah Goldstein} 252e7999fb4SNoah Goldstein 253e7999fb4SNoah Goldsteindefine i1 @shl_maybe_zero_nsw_fail(i8 %s, i8 %cnt) { 254e7999fb4SNoah Goldstein; CHECK-LABEL: @shl_maybe_zero_nsw_fail( 255e7999fb4SNoah Goldstein; CHECK-NEXT: [[V:%.*]] = shl nsw i8 [[S:%.*]], [[CNT:%.*]] 256e7999fb4SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0 257e7999fb4SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 258e7999fb4SNoah Goldstein; 259e7999fb4SNoah Goldstein %v = shl nsw i8 %s, %cnt 260e7999fb4SNoah Goldstein %r = icmp eq i8 %v, 0 261e7999fb4SNoah Goldstein ret i1 %r 262e7999fb4SNoah Goldstein} 263e7999fb4SNoah Goldstein 264e7999fb4SNoah Goldsteindefine i1 @shl_out_of_range_is_poison(i32 %v, i32 %c) { 265e7999fb4SNoah Goldstein; CHECK-LABEL: @shl_out_of_range_is_poison( 266e7999fb4SNoah Goldstein; CHECK-NEXT: ret i1 poison 267e7999fb4SNoah Goldstein; 268e7999fb4SNoah Goldstein %sval = or i32 %v, 32 269e7999fb4SNoah Goldstein %shl = shl i32 %c, %sval 270e7999fb4SNoah Goldstein %z = icmp eq i32 %shl, 0 271e7999fb4SNoah Goldstein ret i1 %z 272e7999fb4SNoah Goldstein} 273107a5e2bSNoah Goldstein 274107a5e2bSNoah Goldsteindefine i1 @lshr_nz_bounded_cnt(i32 %cnt, i32 %y) { 275107a5e2bSNoah Goldstein; CHECK-LABEL: @lshr_nz_bounded_cnt( 276107a5e2bSNoah Goldstein; CHECK-NEXT: [[CNT_ULT4:%.*]] = icmp ult i32 [[CNT:%.*]], 4 277107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[CNT_ULT4]]) 278e846ec57SNoah Goldstein; CHECK-NEXT: ret i1 false 279107a5e2bSNoah Goldstein; 280107a5e2bSNoah Goldstein %cnt_ult4 = icmp ult i32 %cnt, 4 281107a5e2bSNoah Goldstein call void @llvm.assume(i1 %cnt_ult4) 282107a5e2bSNoah Goldstein %val = or i32 %y, 90 283107a5e2bSNoah Goldstein %shl = lshr i32 %val, %cnt 284107a5e2bSNoah Goldstein %r = icmp eq i32 %shl, 0 285107a5e2bSNoah Goldstein ret i1 %r 286107a5e2bSNoah Goldstein} 287107a5e2bSNoah Goldstein 288107a5e2bSNoah Goldsteindefine <2 x i1> @ashr_nz_bounded_cnt_vec(<2 x i32> %x, <2 x i32> %y) { 289107a5e2bSNoah Goldstein; CHECK-LABEL: @ashr_nz_bounded_cnt_vec( 290e846ec57SNoah Goldstein; CHECK-NEXT: ret <2 x i1> zeroinitializer 291107a5e2bSNoah Goldstein; 292107a5e2bSNoah Goldstein %cnt = and <2 x i32> %x, <i32 16, i32 24> 293107a5e2bSNoah Goldstein %val = or <2 x i32> %y, <i32 402784272, i32 268697601> 294107a5e2bSNoah Goldstein %shl = ashr <2 x i32> %val, %cnt 295107a5e2bSNoah Goldstein %r = icmp eq <2 x i32> %shl, zeroinitializer 296107a5e2bSNoah Goldstein ret <2 x i1> %r 297107a5e2bSNoah Goldstein} 298107a5e2bSNoah Goldstein 299107a5e2bSNoah Goldsteindefine i1 @lshr_nz_bounded_cnt_fail(i32 %cnt, i32 %y) { 300107a5e2bSNoah Goldstein; CHECK-LABEL: @lshr_nz_bounded_cnt_fail( 301107a5e2bSNoah Goldstein; CHECK-NEXT: [[CNT_ULT:%.*]] = icmp ult i32 [[CNT:%.*]], 20 302107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[CNT_ULT]]) 303107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL:%.*]] = or i32 [[Y:%.*]], 131072 304107a5e2bSNoah Goldstein; CHECK-NEXT: [[SHL:%.*]] = lshr i32 [[VAL]], [[CNT]] 305107a5e2bSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[SHL]], 0 306107a5e2bSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 307107a5e2bSNoah Goldstein; 308107a5e2bSNoah Goldstein %cnt_ult = icmp ult i32 %cnt, 20 309107a5e2bSNoah Goldstein call void @llvm.assume(i1 %cnt_ult) 310107a5e2bSNoah Goldstein %val = or i32 %y, 131072 311107a5e2bSNoah Goldstein %shl = lshr i32 %val, %cnt 312107a5e2bSNoah Goldstein %r = icmp eq i32 %shl, 0 313107a5e2bSNoah Goldstein ret i1 %r 314107a5e2bSNoah Goldstein} 315107a5e2bSNoah Goldstein 316107a5e2bSNoah Goldsteindefine <2 x i1> @ashr_nz_bounded_cnt_vec_fail(<2 x i32> %x, <2 x i32> %y) { 317107a5e2bSNoah Goldstein; CHECK-LABEL: @ashr_nz_bounded_cnt_vec_fail( 318*38fffa63SPaul Walker; CHECK-NEXT: [[CNT:%.*]] = and <2 x i32> [[X:%.*]], splat (i32 24) 319107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL:%.*]] = or <2 x i32> [[Y:%.*]], <i32 131088, i32 268697601> 320107a5e2bSNoah Goldstein; CHECK-NEXT: [[SHL:%.*]] = ashr <2 x i32> [[VAL]], [[CNT]] 321107a5e2bSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i32> [[SHL]], zeroinitializer 322107a5e2bSNoah Goldstein; CHECK-NEXT: ret <2 x i1> [[R]] 323107a5e2bSNoah Goldstein; 324107a5e2bSNoah Goldstein %cnt = and <2 x i32> %x, <i32 24, i32 24> 325107a5e2bSNoah Goldstein %val = or <2 x i32> %y, <i32 131088, i32 268697601> 326107a5e2bSNoah Goldstein %shl = ashr <2 x i32> %val, %cnt 327107a5e2bSNoah Goldstein %r = icmp eq <2 x i32> %shl, zeroinitializer 328107a5e2bSNoah Goldstein ret <2 x i1> %r 329107a5e2bSNoah Goldstein} 330107a5e2bSNoah Goldstein 331107a5e2bSNoah Goldsteindefine i1 @lshr_nonzero_and_shift_out_zeros(i32 %cnt, i32 %y) { 332107a5e2bSNoah Goldstein; CHECK-LABEL: @lshr_nonzero_and_shift_out_zeros( 333107a5e2bSNoah Goldstein; CHECK-NEXT: [[CNT_ULT:%.*]] = icmp ult i32 [[CNT:%.*]], 4 334107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[CNT_ULT]]) 335107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL:%.*]] = and i32 [[Y:%.*]], -131072 336107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL_NZ:%.*]] = icmp ne i32 [[VAL]], 0 337107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[VAL_NZ]]) 338e846ec57SNoah Goldstein; CHECK-NEXT: ret i1 false 339107a5e2bSNoah Goldstein; 340107a5e2bSNoah Goldstein %cnt_ult = icmp ult i32 %cnt, 4 341107a5e2bSNoah Goldstein call void @llvm.assume(i1 %cnt_ult) 342107a5e2bSNoah Goldstein %val = and i32 %y, -131072 343107a5e2bSNoah Goldstein %val_nz = icmp ne i32 %val, 0 344107a5e2bSNoah Goldstein call void @llvm.assume(i1 %val_nz) 345107a5e2bSNoah Goldstein %shl = lshr i32 %val, %cnt 346107a5e2bSNoah Goldstein %r = icmp eq i32 %shl, 0 347107a5e2bSNoah Goldstein ret i1 %r 348107a5e2bSNoah Goldstein} 349107a5e2bSNoah Goldstein 350107a5e2bSNoah Goldsteindefine i1 @ashr_nonzero_and_shift_out_zeros(i32 %ccnt, i32 %y) { 351107a5e2bSNoah Goldstein; CHECK-LABEL: @ashr_nonzero_and_shift_out_zeros( 352107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL:%.*]] = and i32 [[Y:%.*]], -131072 353107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL_NZ:%.*]] = icmp ne i32 [[VAL]], 0 354107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[VAL_NZ]]) 355e846ec57SNoah Goldstein; CHECK-NEXT: ret i1 false 356107a5e2bSNoah Goldstein; 357107a5e2bSNoah Goldstein %cnt = and i32 %ccnt, 7 358107a5e2bSNoah Goldstein %val = and i32 %y, -131072 359107a5e2bSNoah Goldstein %val_nz = icmp ne i32 %val, 0 360107a5e2bSNoah Goldstein call void @llvm.assume(i1 %val_nz) 361107a5e2bSNoah Goldstein %shl = ashr i32 %val, %cnt 362107a5e2bSNoah Goldstein %r = icmp eq i32 %shl, 0 363107a5e2bSNoah Goldstein ret i1 %r 364107a5e2bSNoah Goldstein} 365107a5e2bSNoah Goldstein 366107a5e2bSNoah Goldsteindefine i1 @shl_nonzero_and_shift_out_zeros(i32 %ccnt, i32 %y) { 367107a5e2bSNoah Goldstein; CHECK-LABEL: @shl_nonzero_and_shift_out_zeros( 368107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL:%.*]] = and i32 [[Y:%.*]], 131071 369107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL_NZ:%.*]] = icmp ne i32 [[VAL]], 0 370107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[VAL_NZ]]) 371e846ec57SNoah Goldstein; CHECK-NEXT: ret i1 false 372107a5e2bSNoah Goldstein; 373107a5e2bSNoah Goldstein %cnt = and i32 %ccnt, 6 374107a5e2bSNoah Goldstein %val = and i32 %y, 131071 375107a5e2bSNoah Goldstein %val_nz = icmp ne i32 %val, 0 376107a5e2bSNoah Goldstein call void @llvm.assume(i1 %val_nz) 377107a5e2bSNoah Goldstein %shl = shl i32 %val, %cnt 378107a5e2bSNoah Goldstein %r = icmp eq i32 %shl, 0 379107a5e2bSNoah Goldstein ret i1 %r 380107a5e2bSNoah Goldstein} 381107a5e2bSNoah Goldstein 382107a5e2bSNoah Goldsteindefine i1 @lshr_nonzero_and_shift_out_zeros_fail(i32 %cnt, i32 %y) { 383107a5e2bSNoah Goldstein; CHECK-LABEL: @lshr_nonzero_and_shift_out_zeros_fail( 384107a5e2bSNoah Goldstein; CHECK-NEXT: [[CNT_ULT:%.*]] = icmp ult i32 [[CNT:%.*]], 19 385107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[CNT_ULT]]) 386107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL:%.*]] = and i32 [[Y:%.*]], -131072 387107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL_NZ:%.*]] = icmp ne i32 [[VAL]], 0 388107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[VAL_NZ]]) 389107a5e2bSNoah Goldstein; CHECK-NEXT: [[SHL:%.*]] = lshr i32 [[VAL]], [[CNT]] 390107a5e2bSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[SHL]], 0 391107a5e2bSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 392107a5e2bSNoah Goldstein; 393107a5e2bSNoah Goldstein %cnt_ult = icmp ult i32 %cnt, 19 394107a5e2bSNoah Goldstein call void @llvm.assume(i1 %cnt_ult) 395107a5e2bSNoah Goldstein %val = and i32 %y, -131072 396107a5e2bSNoah Goldstein %val_nz = icmp ne i32 %val, 0 397107a5e2bSNoah Goldstein call void @llvm.assume(i1 %val_nz) 398107a5e2bSNoah Goldstein %shl = lshr i32 %val, %cnt 399107a5e2bSNoah Goldstein %r = icmp eq i32 %shl, 0 400107a5e2bSNoah Goldstein ret i1 %r 401107a5e2bSNoah Goldstein} 402107a5e2bSNoah Goldstein 403107a5e2bSNoah Goldsteindefine i1 @ashr_nonzero_and_shift_out_zeros_fail(i32 %ccnt, i32 %y) { 404107a5e2bSNoah Goldstein; CHECK-LABEL: @ashr_nonzero_and_shift_out_zeros_fail( 405107a5e2bSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i32 [[CCNT:%.*]], 18 406107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL:%.*]] = and i32 [[Y:%.*]], -131072 407107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL_NZ:%.*]] = icmp ne i32 [[VAL]], 0 408107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[VAL_NZ]]) 409107a5e2bSNoah Goldstein; CHECK-NEXT: [[SHL:%.*]] = ashr i32 [[VAL]], [[CNT]] 410107a5e2bSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[SHL]], 0 411107a5e2bSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 412107a5e2bSNoah Goldstein; 413107a5e2bSNoah Goldstein %cnt = and i32 %ccnt, 18 414107a5e2bSNoah Goldstein %val = and i32 %y, -131072 415107a5e2bSNoah Goldstein %val_nz = icmp ne i32 %val, 0 416107a5e2bSNoah Goldstein call void @llvm.assume(i1 %val_nz) 417107a5e2bSNoah Goldstein %shl = ashr i32 %val, %cnt 418107a5e2bSNoah Goldstein %r = icmp eq i32 %shl, 0 419107a5e2bSNoah Goldstein ret i1 %r 420107a5e2bSNoah Goldstein} 421107a5e2bSNoah Goldstein 422107a5e2bSNoah Goldsteindefine i1 @shl_nonzero_and_shift_out_zeros_fail(i32 %ccnt, i32 %y) { 423107a5e2bSNoah Goldstein; CHECK-LABEL: @shl_nonzero_and_shift_out_zeros_fail( 424107a5e2bSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i32 [[CCNT:%.*]], 6 425107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL:%.*]] = and i32 [[Y:%.*]], 268435455 426107a5e2bSNoah Goldstein; CHECK-NEXT: [[VAL_NZ:%.*]] = icmp ne i32 [[VAL]], 0 427107a5e2bSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[VAL_NZ]]) 428107a5e2bSNoah Goldstein; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[VAL]], [[CNT]] 429107a5e2bSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[SHL]], 0 430107a5e2bSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 431107a5e2bSNoah Goldstein; 432107a5e2bSNoah Goldstein %cnt = and i32 %ccnt, 6 433107a5e2bSNoah Goldstein %val = and i32 %y, 268435455 434107a5e2bSNoah Goldstein %val_nz = icmp ne i32 %val, 0 435107a5e2bSNoah Goldstein call void @llvm.assume(i1 %val_nz) 436107a5e2bSNoah Goldstein %shl = shl i32 %val, %cnt 437107a5e2bSNoah Goldstein %r = icmp eq i32 %shl, 0 438107a5e2bSNoah Goldstein ret i1 %r 439107a5e2bSNoah Goldstein} 44073f5f1a8SNoah Goldstein 44173f5f1a8SNoah Goldsteindefine i1 @sub_nonzero_ops_ne(i8 %xx, i8 %yy, i8 %z) { 44273f5f1a8SNoah Goldstein; CHECK-LABEL: @sub_nonzero_ops_ne( 4439b3c865dSNoah Goldstein; CHECK-NEXT: ret i1 false 44473f5f1a8SNoah Goldstein; 44573f5f1a8SNoah Goldstein %x = and i8 %xx, 191 44673f5f1a8SNoah Goldstein %y = or i8 %yy, 64 44773f5f1a8SNoah Goldstein %s = sub i8 %x, %y 44873f5f1a8SNoah Goldstein %exp = or i8 %z, %s 44973f5f1a8SNoah Goldstein %r = icmp eq i8 %exp, 0 45073f5f1a8SNoah Goldstein ret i1 %r 45173f5f1a8SNoah Goldstein} 45273f5f1a8SNoah Goldstein 45373f5f1a8SNoah Goldsteindefine i1 @sub_nonzero_ops_ne_fail(i8 %xx, i8 %yy, i8 %z) { 45473f5f1a8SNoah Goldstein; CHECK-LABEL: @sub_nonzero_ops_ne_fail( 45573f5f1a8SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], -64 45673f5f1a8SNoah Goldstein; CHECK-NEXT: [[Y:%.*]] = or i8 [[YY:%.*]], 64 45773f5f1a8SNoah Goldstein; CHECK-NEXT: [[S:%.*]] = sub i8 [[X]], [[Y]] 45873f5f1a8SNoah Goldstein; CHECK-NEXT: [[EXP:%.*]] = or i8 [[Z:%.*]], [[S]] 45973f5f1a8SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[EXP]], 0 46073f5f1a8SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 46173f5f1a8SNoah Goldstein; 46273f5f1a8SNoah Goldstein %x = and i8 %xx, 192 46373f5f1a8SNoah Goldstein %y = or i8 %yy, 64 46473f5f1a8SNoah Goldstein %s = sub i8 %x, %y 46573f5f1a8SNoah Goldstein %exp = or i8 %z, %s 46673f5f1a8SNoah Goldstein %r = icmp eq i8 %exp, 0 46773f5f1a8SNoah Goldstein ret i1 %r 46873f5f1a8SNoah Goldstein} 46973f5f1a8SNoah Goldstein 47073f5f1a8SNoah Goldsteindefine i1 @add_nonzero_nuw(i8 %x, i8 %y) { 47173f5f1a8SNoah Goldstein; CHECK-LABEL: @add_nonzero_nuw( 47273f5f1a8SNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp ne i8 [[X:%.*]], 0 47373f5f1a8SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 47475b48b40SNoah Goldstein; CHECK-NEXT: ret i1 false 47573f5f1a8SNoah Goldstein; 47673f5f1a8SNoah Goldstein %x_nz = icmp ne i8 %x, 0 47773f5f1a8SNoah Goldstein call void @llvm.assume(i1 %x_nz) 47873f5f1a8SNoah Goldstein %a = add nuw i8 %x, %y 47973f5f1a8SNoah Goldstein %r = icmp eq i8 %a, 0 48073f5f1a8SNoah Goldstein ret i1 %r 48173f5f1a8SNoah Goldstein} 48273f5f1a8SNoah Goldstein 48373f5f1a8SNoah Goldsteindefine i1 @add_nonzero_nsw_fail(i8 %x, i8 %y) { 48473f5f1a8SNoah Goldstein; CHECK-LABEL: @add_nonzero_nsw_fail( 48573f5f1a8SNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp ne i8 [[X:%.*]], 0 48673f5f1a8SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 48773f5f1a8SNoah Goldstein; CHECK-NEXT: [[A:%.*]] = add nsw i8 [[X]], [[Y:%.*]] 48873f5f1a8SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[A]], 0 48973f5f1a8SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 49073f5f1a8SNoah Goldstein; 49173f5f1a8SNoah Goldstein %x_nz = icmp ne i8 %x, 0 49273f5f1a8SNoah Goldstein call void @llvm.assume(i1 %x_nz) 49373f5f1a8SNoah Goldstein %a = add nsw i8 %x, %y 49473f5f1a8SNoah Goldstein %r = icmp eq i8 %a, 0 49573f5f1a8SNoah Goldstein ret i1 %r 49673f5f1a8SNoah Goldstein} 49773f5f1a8SNoah Goldstein 49873f5f1a8SNoah Goldsteindefine i1 @udiv_y_le_x(i8 %xx, i8 %yy, i8 %z) { 49973f5f1a8SNoah Goldstein; CHECK-LABEL: @udiv_y_le_x( 500d8e9dd33SNoah Goldstein; CHECK-NEXT: ret i1 false 50173f5f1a8SNoah Goldstein; 50273f5f1a8SNoah Goldstein %x = or i8 %xx, 7 50373f5f1a8SNoah Goldstein %y = and i8 %yy, 7 50473f5f1a8SNoah Goldstein %d = udiv i8 %x, %y 50573f5f1a8SNoah Goldstein %o = or i8 %d, %z 50673f5f1a8SNoah Goldstein %r = icmp eq i8 %o, 0 50773f5f1a8SNoah Goldstein ret i1 %r 50873f5f1a8SNoah Goldstein} 50973f5f1a8SNoah Goldstein 51073f5f1a8SNoah Goldsteindefine i1 @udiv_y_le_x_fail(i8 %xx, i8 %yy, i8 %z) { 51173f5f1a8SNoah Goldstein; CHECK-LABEL: @udiv_y_le_x_fail( 51273f5f1a8SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 6 51373f5f1a8SNoah Goldstein; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], 7 51473f5f1a8SNoah Goldstein; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X]], [[Y]] 51573f5f1a8SNoah Goldstein; CHECK-NEXT: [[O:%.*]] = or i8 [[D]], [[Z:%.*]] 51673f5f1a8SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[O]], 0 51773f5f1a8SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 51873f5f1a8SNoah Goldstein; 51973f5f1a8SNoah Goldstein %x = or i8 %xx, 6 52073f5f1a8SNoah Goldstein %y = and i8 %yy, 7 52173f5f1a8SNoah Goldstein %d = udiv i8 %x, %y 52273f5f1a8SNoah Goldstein %o = or i8 %d, %z 52373f5f1a8SNoah Goldstein %r = icmp eq i8 %o, 0 52473f5f1a8SNoah Goldstein ret i1 %r 52573f5f1a8SNoah Goldstein} 52674157bf6SNoah Goldstein 52774157bf6SNoah Goldsteindefine i1 @fshr_non_zero(i8 %x, i8 %y, i8 %z) { 52874157bf6SNoah Goldstein; CHECK-LABEL: @fshr_non_zero( 52974157bf6SNoah Goldstein; CHECK-NEXT: [[PRED0:%.*]] = icmp ne i8 [[X:%.*]], 0 53074157bf6SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[PRED0]]) 5314cd1b674SNoah Goldstein; CHECK-NEXT: ret i1 false 53274157bf6SNoah Goldstein; 53374157bf6SNoah Goldstein %pred0 = icmp ne i8 %x, 0 53474157bf6SNoah Goldstein call void @llvm.assume(i1 %pred0) 53574157bf6SNoah Goldstein %v = tail call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 %y) 53674157bf6SNoah Goldstein %or = or i8 %v, %z 53774157bf6SNoah Goldstein %r = icmp eq i8 %or, 0 53874157bf6SNoah Goldstein ret i1 %r 53974157bf6SNoah Goldstein} 54074157bf6SNoah Goldstein 54174157bf6SNoah Goldsteindefine i1 @fshr_non_zero_fail(i8 %x, i8 %y, i8 %z, i8 %w) { 54274157bf6SNoah Goldstein; CHECK-LABEL: @fshr_non_zero_fail( 54374157bf6SNoah Goldstein; CHECK-NEXT: [[PRED0:%.*]] = icmp ne i8 [[X:%.*]], 0 54474157bf6SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[PRED0]]) 54574157bf6SNoah Goldstein; CHECK-NEXT: [[PRED1:%.*]] = icmp ne i8 [[W:%.*]], 0 54674157bf6SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[PRED1]]) 54774157bf6SNoah Goldstein; CHECK-NEXT: [[V:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[X]], i8 [[W]], i8 [[Y:%.*]]) 54874157bf6SNoah Goldstein; CHECK-NEXT: [[OR:%.*]] = or i8 [[V]], [[Z:%.*]] 54974157bf6SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[OR]], 0 55074157bf6SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 55174157bf6SNoah Goldstein; 55274157bf6SNoah Goldstein %pred0 = icmp ne i8 %x, 0 55374157bf6SNoah Goldstein call void @llvm.assume(i1 %pred0) 55474157bf6SNoah Goldstein %pred1 = icmp ne i8 %w, 0 55574157bf6SNoah Goldstein call void @llvm.assume(i1 %pred1) 55674157bf6SNoah Goldstein %v = tail call i8 @llvm.fshr.i8(i8 %x, i8 %w, i8 %y) 55774157bf6SNoah Goldstein %or = or i8 %v, %z 55874157bf6SNoah Goldstein %r = icmp eq i8 %or, 0 55974157bf6SNoah Goldstein ret i1 %r 56074157bf6SNoah Goldstein} 56174157bf6SNoah Goldstein 56274157bf6SNoah Goldsteindefine i1 @fshl_non_zero(i8 %x, i8 %y, i8 %z) { 56374157bf6SNoah Goldstein; CHECK-LABEL: @fshl_non_zero( 56474157bf6SNoah Goldstein; CHECK-NEXT: [[PRED0:%.*]] = icmp ne i8 [[X:%.*]], 0 56574157bf6SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[PRED0]]) 5664cd1b674SNoah Goldstein; CHECK-NEXT: ret i1 false 56774157bf6SNoah Goldstein; 56874157bf6SNoah Goldstein %pred0 = icmp ne i8 %x, 0 56974157bf6SNoah Goldstein call void @llvm.assume(i1 %pred0) 57074157bf6SNoah Goldstein %v = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %y) 57174157bf6SNoah Goldstein %or = or i8 %v, %z 57274157bf6SNoah Goldstein %r = icmp eq i8 %or, 0 57374157bf6SNoah Goldstein ret i1 %r 57474157bf6SNoah Goldstein} 57574157bf6SNoah Goldstein 57674157bf6SNoah Goldsteindefine i1 @fshl_non_zero_fail(i8 %x, i8 %y, i8 %z, i8 %w) { 57774157bf6SNoah Goldstein; CHECK-LABEL: @fshl_non_zero_fail( 57874157bf6SNoah Goldstein; CHECK-NEXT: [[PRED0:%.*]] = icmp ne i8 [[X:%.*]], 0 57974157bf6SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[PRED0]]) 58074157bf6SNoah Goldstein; CHECK-NEXT: [[PRED1:%.*]] = icmp ne i8 [[W:%.*]], 0 58174157bf6SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[PRED1]]) 58274157bf6SNoah Goldstein; CHECK-NEXT: [[V:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X]], i8 [[W]], i8 [[Y:%.*]]) 58374157bf6SNoah Goldstein; CHECK-NEXT: [[OR:%.*]] = or i8 [[V]], [[Z:%.*]] 58474157bf6SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[OR]], 0 58574157bf6SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 58674157bf6SNoah Goldstein; 58774157bf6SNoah Goldstein %pred0 = icmp ne i8 %x, 0 58874157bf6SNoah Goldstein call void @llvm.assume(i1 %pred0) 58974157bf6SNoah Goldstein %pred1 = icmp ne i8 %w, 0 59074157bf6SNoah Goldstein call void @llvm.assume(i1 %pred1) 59174157bf6SNoah Goldstein %v = tail call i8 @llvm.fshl.i8(i8 %x, i8 %w, i8 %y) 59274157bf6SNoah Goldstein %or = or i8 %v, %z 59374157bf6SNoah Goldstein %r = icmp eq i8 %or, 0 59474157bf6SNoah Goldstein ret i1 %r 59574157bf6SNoah Goldstein} 596f7bf984eSNoah Goldstein 597f7bf984eSNoah Goldsteindefine i1 @bitcast_nonzero(<2 x i8> %xx, i16 %ind) { 598f7bf984eSNoah Goldstein; CHECK-LABEL: @bitcast_nonzero( 599c7f7f601SNoah Goldstein; CHECK-NEXT: ret i1 false 600f7bf984eSNoah Goldstein; 601f7bf984eSNoah Goldstein %xa = add nuw nsw <2 x i8> %xx, <i8 1, i8 1> 602f7bf984eSNoah Goldstein %x = bitcast <2 x i8> %xa to i16 603f7bf984eSNoah Goldstein %z = or i16 %x, %ind 604f7bf984eSNoah Goldstein %r = icmp eq i16 %z, 0 605f7bf984eSNoah Goldstein ret i1 %r 606f7bf984eSNoah Goldstein} 607f7bf984eSNoah Goldstein 608f7bf984eSNoah Goldsteindefine i1 @bitcast_todo_partial_nonzero_vec_to_int(<2 x i8> %xx, i16 %ind) { 609f7bf984eSNoah Goldstein; CHECK-LABEL: @bitcast_todo_partial_nonzero_vec_to_int( 610f7bf984eSNoah Goldstein; CHECK-NEXT: [[XA:%.*]] = add nuw nsw <2 x i8> [[XX:%.*]], <i8 1, i8 0> 611f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = bitcast <2 x i8> [[XA]] to i16 612f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i16 [[X]], [[IND:%.*]] 613f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i16 [[Z]], 0 614f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 615f7bf984eSNoah Goldstein; 616f7bf984eSNoah Goldstein %xa = add nuw nsw <2 x i8> %xx, <i8 1, i8 0> 617f7bf984eSNoah Goldstein %x = bitcast <2 x i8> %xa to i16 618f7bf984eSNoah Goldstein %z = or i16 %x, %ind 619f7bf984eSNoah Goldstein %r = icmp eq i16 %z, 0 620f7bf984eSNoah Goldstein ret i1 %r 621f7bf984eSNoah Goldstein} 622f7bf984eSNoah Goldstein 623f7bf984eSNoah Goldsteindefine <2 x i1> @bitcast_fail_nonzero_int_to_vec(i16 %xx, <2 x i8> %ind) { 624f7bf984eSNoah Goldstein; CHECK-LABEL: @bitcast_fail_nonzero_int_to_vec( 625f7bf984eSNoah Goldstein; CHECK-NEXT: [[XA:%.*]] = add nuw nsw i16 [[XX:%.*]], 1 626f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = bitcast i16 [[XA]] to <2 x i8> 627f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or <2 x i8> [[X]], [[IND:%.*]] 628f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[Z]], zeroinitializer 629f7bf984eSNoah Goldstein; CHECK-NEXT: ret <2 x i1> [[R]] 630f7bf984eSNoah Goldstein; 631f7bf984eSNoah Goldstein %xa = add nuw nsw i16 %xx, 1 632f7bf984eSNoah Goldstein %x = bitcast i16 %xa to <2 x i8> 633f7bf984eSNoah Goldstein %z = or <2 x i8> %x, %ind 634f7bf984eSNoah Goldstein %r = icmp eq <2 x i8> %z, zeroinitializer 635f7bf984eSNoah Goldstein ret <2 x i1> %r 636f7bf984eSNoah Goldstein} 637f7bf984eSNoah Goldstein 638f7bf984eSNoah Goldsteindefine <2 x i1> @bitcast_veci8_to_veci16(<4 x i8> %xx, <2 x i16> %ind) { 639f7bf984eSNoah Goldstein; CHECK-LABEL: @bitcast_veci8_to_veci16( 640c7f7f601SNoah Goldstein; CHECK-NEXT: ret <2 x i1> zeroinitializer 641f7bf984eSNoah Goldstein; 642f7bf984eSNoah Goldstein %xa = add nuw nsw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1> 643f7bf984eSNoah Goldstein %x = bitcast <4 x i8> %xa to <2 x i16> 644f7bf984eSNoah Goldstein %z = or <2 x i16> %x, %ind 645f7bf984eSNoah Goldstein %r = icmp eq <2 x i16> %z, zeroinitializer 646f7bf984eSNoah Goldstein ret <2 x i1> %r 647f7bf984eSNoah Goldstein} 648f7bf984eSNoah Goldstein 649f7bf984eSNoah Goldsteindefine <3 x i1> @bitcast_veci3_to_veci4_fail_not_multiple(<4 x i3> %xx, <3 x i4> %ind) { 650f7bf984eSNoah Goldstein; CHECK-LABEL: @bitcast_veci3_to_veci4_fail_not_multiple( 651*38fffa63SPaul Walker; CHECK-NEXT: [[XA:%.*]] = add nuw nsw <4 x i3> [[XX:%.*]], splat (i3 1) 652f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = bitcast <4 x i3> [[XA]] to <3 x i4> 653f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or <3 x i4> [[X]], [[IND:%.*]] 654f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq <3 x i4> [[Z]], zeroinitializer 655f7bf984eSNoah Goldstein; CHECK-NEXT: ret <3 x i1> [[R]] 656f7bf984eSNoah Goldstein; 657f7bf984eSNoah Goldstein %xa = add nuw nsw <4 x i3> %xx, <i3 1, i3 1, i3 1, i3 1> 658f7bf984eSNoah Goldstein %x = bitcast <4 x i3> %xa to <3 x i4> 659f7bf984eSNoah Goldstein %z = or <3 x i4> %x, %ind 660f7bf984eSNoah Goldstein %r = icmp eq <3 x i4> %z, zeroinitializer 661f7bf984eSNoah Goldstein ret <3 x i1> %r 662f7bf984eSNoah Goldstein} 663f7bf984eSNoah Goldstein 664f7bf984eSNoah Goldsteindefine <4 x i1> @bitcast_fail_veci16_to_veci8(<2 x i16> %xx, <4 x i8> %ind) { 665f7bf984eSNoah Goldstein; CHECK-LABEL: @bitcast_fail_veci16_to_veci8( 666*38fffa63SPaul Walker; CHECK-NEXT: [[XA:%.*]] = add nuw nsw <2 x i16> [[XX:%.*]], splat (i16 1) 667f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = bitcast <2 x i16> [[XA]] to <4 x i8> 668f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or <4 x i8> [[X]], [[IND:%.*]] 669f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq <4 x i8> [[Z]], zeroinitializer 670f7bf984eSNoah Goldstein; CHECK-NEXT: ret <4 x i1> [[R]] 671f7bf984eSNoah Goldstein; 672f7bf984eSNoah Goldstein %xa = add nuw nsw <2 x i16> %xx, <i16 1, i16 1> 673f7bf984eSNoah Goldstein %x = bitcast <2 x i16> %xa to <4 x i8> 674f7bf984eSNoah Goldstein %z = or <4 x i8> %x, %ind 675f7bf984eSNoah Goldstein %r = icmp eq <4 x i8> %z, zeroinitializer 676f7bf984eSNoah Goldstein ret <4 x i1> %r 677f7bf984eSNoah Goldstein} 678f7bf984eSNoah Goldstein 679f7bf984eSNoah Goldsteindefine i1 @bitcast_nonzero_fail_dont_check_float(float %xx, i32 %ind) { 680f7bf984eSNoah Goldstein; CHECK-LABEL: @bitcast_nonzero_fail_dont_check_float( 681f7bf984eSNoah Goldstein; CHECK-NEXT: [[XA:%.*]] = call float @llvm.maximum.f32(float [[XX:%.*]], float 1.000000e+00) 682f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = bitcast float [[XA]] to i32 683f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i32 [[X]], [[IND:%.*]] 684f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[Z]], 0 685f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 686f7bf984eSNoah Goldstein; 687f7bf984eSNoah Goldstein %xa = call float @llvm.maximum.f32(float %xx, float 1.000000e+00) 688f7bf984eSNoah Goldstein %x = bitcast float %xa to i32 689f7bf984eSNoah Goldstein %z = or i32 %x, %ind 690f7bf984eSNoah Goldstein %r = icmp eq i32 %z, 0 691f7bf984eSNoah Goldstein ret i1 %r 692f7bf984eSNoah Goldstein} 693f7bf984eSNoah Goldstein 694f7bf984eSNoah Goldsteindefine i1 @ctlz_true_nonzero(i8 %xx, i8 %ind) { 695f7bf984eSNoah Goldstein; CHECK-LABEL: @ctlz_true_nonzero( 696ea5a0d4bSNoah Goldstein; CHECK-NEXT: ret i1 false 697f7bf984eSNoah Goldstein; 698f7bf984eSNoah Goldstein %xs = lshr i8 %xx, 1 699f7bf984eSNoah Goldstein %x = call i8 @llvm.ctlz.i8(i8 %xs, i1 true) 700f7bf984eSNoah Goldstein %z = or i8 %x, %ind 701f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 702f7bf984eSNoah Goldstein ret i1 %r 703f7bf984eSNoah Goldstein} 704f7bf984eSNoah Goldstein 705f7bf984eSNoah Goldsteindefine i1 @ctlz_false_nonzero(i8 %xx, i8 %ind) { 706f7bf984eSNoah Goldstein; CHECK-LABEL: @ctlz_false_nonzero( 707ea5a0d4bSNoah Goldstein; CHECK-NEXT: ret i1 false 708f7bf984eSNoah Goldstein; 709f7bf984eSNoah Goldstein %xa = and i8 %xx, 127 710f7bf984eSNoah Goldstein %x = call i8 @llvm.ctlz.i8(i8 %xa, i1 true) 711f7bf984eSNoah Goldstein %z = or i8 %x, %ind 712f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 713f7bf984eSNoah Goldstein ret i1 %r 714f7bf984eSNoah Goldstein} 715f7bf984eSNoah Goldstein 716f7bf984eSNoah Goldsteindefine i1 @ctlz_nonzero_fail_maybe_neg(i8 %xx, i8 %ind) { 717f7bf984eSNoah Goldstein; CHECK-LABEL: @ctlz_nonzero_fail_maybe_neg( 718f7bf984eSNoah Goldstein; CHECK-NEXT: [[XS:%.*]] = ashr i8 [[XX:%.*]], 1 719f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.ctlz.i8(i8 [[XS]], i1 true) 720f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 721f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 722f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 723f7bf984eSNoah Goldstein; 724f7bf984eSNoah Goldstein %xs = ashr i8 %xx, 1 725f7bf984eSNoah Goldstein %x = call i8 @llvm.ctlz.i8(i8 %xs, i1 true) 726f7bf984eSNoah Goldstein %z = or i8 %x, %ind 727f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 728f7bf984eSNoah Goldstein ret i1 %r 729f7bf984eSNoah Goldstein} 730f7bf984eSNoah Goldstein 731f7bf984eSNoah Goldsteindefine i1 @cttz_true_nonzero(i8 %xx, i8 %ind) { 732f7bf984eSNoah Goldstein; CHECK-LABEL: @cttz_true_nonzero( 733ea5a0d4bSNoah Goldstein; CHECK-NEXT: ret i1 false 734f7bf984eSNoah Goldstein; 735f7bf984eSNoah Goldstein %xs = shl i8 %xx, 1 736f7bf984eSNoah Goldstein %x = call i8 @llvm.cttz.i8(i8 %xs, i1 true) 737f7bf984eSNoah Goldstein %z = or i8 %x, %ind 738f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 739f7bf984eSNoah Goldstein ret i1 %r 740f7bf984eSNoah Goldstein} 741f7bf984eSNoah Goldstein 742f7bf984eSNoah Goldsteindefine i1 @cttz_false_nonzero(i8 %xx, i8 %ind) { 743f7bf984eSNoah Goldstein; CHECK-LABEL: @cttz_false_nonzero( 744ea5a0d4bSNoah Goldstein; CHECK-NEXT: ret i1 false 745f7bf984eSNoah Goldstein; 746f7bf984eSNoah Goldstein %xa = and i8 %xx, -2 747f7bf984eSNoah Goldstein %x = call i8 @llvm.cttz.i8(i8 %xa, i1 true) 748f7bf984eSNoah Goldstein %z = or i8 %x, %ind 749f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 750f7bf984eSNoah Goldstein ret i1 %r 751f7bf984eSNoah Goldstein} 752f7bf984eSNoah Goldstein 753f7bf984eSNoah Goldsteindefine i1 @cttz_nonzero_fail_maybe_odd(i8 %xx, i8 %cnt, i8 %ind) { 754f7bf984eSNoah Goldstein; CHECK-LABEL: @cttz_nonzero_fail_maybe_odd( 755f7bf984eSNoah Goldstein; CHECK-NEXT: [[XS:%.*]] = shl i8 [[XX:%.*]], [[CNT:%.*]] 756f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.cttz.i8(i8 [[XS]], i1 true) 757f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 758f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 759f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 760f7bf984eSNoah Goldstein; 761f7bf984eSNoah Goldstein %xs = shl i8 %xx, %cnt 762f7bf984eSNoah Goldstein %x = call i8 @llvm.cttz.i8(i8 %xs, i1 true) 763f7bf984eSNoah Goldstein %z = or i8 %x, %ind 764f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 765f7bf984eSNoah Goldstein ret i1 %r 766f7bf984eSNoah Goldstein} 767f7bf984eSNoah Goldstein 768f7bf984eSNoah Goldsteindefine i1 @mul_nonzero_odd(i8 %xx, i8 %y, i8 %ind) { 769f7bf984eSNoah Goldstein; CHECK-LABEL: @mul_nonzero_odd( 770f7bf984eSNoah Goldstein; CHECK-NEXT: [[Y_NZ:%.*]] = icmp ne i8 [[Y:%.*]], 0 771f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[Y_NZ]]) 7725eedfff6SNoah Goldstein; CHECK-NEXT: ret i1 false 773f7bf984eSNoah Goldstein; 774f7bf984eSNoah Goldstein %xo = or i8 %xx, 1 775f7bf984eSNoah Goldstein %y_nz = icmp ne i8 %y, 0 776f7bf984eSNoah Goldstein call void @llvm.assume(i1 %y_nz) 777f7bf984eSNoah Goldstein %x = mul i8 %xo, %y 778f7bf984eSNoah Goldstein %z = or i8 %x, %ind 779f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 780f7bf984eSNoah Goldstein ret i1 %r 781f7bf984eSNoah Goldstein} 782f7bf984eSNoah Goldstein 783f7bf984eSNoah Goldsteindefine i1 @mul_nonzero_odd_fail_y_maybe_zero(i8 %xx, i8 %y, i8 %ind) { 784f7bf984eSNoah Goldstein; CHECK-LABEL: @mul_nonzero_odd_fail_y_maybe_zero( 785f7bf984eSNoah Goldstein; CHECK-NEXT: [[XO:%.*]] = or i8 [[XX:%.*]], 1 786f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = mul i8 [[XO]], [[Y:%.*]] 787f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 788f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 789f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 790f7bf984eSNoah Goldstein; 791f7bf984eSNoah Goldstein %xo = or i8 %xx, 1 792f7bf984eSNoah Goldstein %x = mul i8 %xo, %y 793f7bf984eSNoah Goldstein %z = or i8 %x, %ind 794f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 795f7bf984eSNoah Goldstein ret i1 %r 796f7bf984eSNoah Goldstein} 797f7bf984eSNoah Goldstein 798f7bf984eSNoah Goldsteindefine i1 @sshl_nonzero(i8 %xx, i8 %y, i8 %ind) { 799f7bf984eSNoah Goldstein; CHECK-LABEL: @sshl_nonzero( 800f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp ne i8 [[XX:%.*]], 0 801f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 802f1dfa493SNoah Goldstein; CHECK-NEXT: ret i1 false 803f7bf984eSNoah Goldstein; 804f7bf984eSNoah Goldstein %x_nz = icmp ne i8 %xx, 0 805f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_nz) 806f7bf984eSNoah Goldstein %x = call i8 @llvm.sshl.sat.i8(i8 %xx, i8 %y) 807f7bf984eSNoah Goldstein %z = or i8 %x, %ind 808f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 809f7bf984eSNoah Goldstein ret i1 %r 810f7bf984eSNoah Goldstein} 811f7bf984eSNoah Goldstein 812f7bf984eSNoah Goldsteindefine i1 @sshl_nonzero_fail_x_maybe_z(i8 %xx, i8 %y, i8 %ind) { 813f7bf984eSNoah Goldstein; CHECK-LABEL: @sshl_nonzero_fail_x_maybe_z( 814f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.sshl.sat.i8(i8 [[XX:%.*]], i8 [[Y:%.*]]) 815f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 816f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 817f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 818f7bf984eSNoah Goldstein; 819f7bf984eSNoah Goldstein %x = call i8 @llvm.sshl.sat.i8(i8 %xx, i8 %y) 820f7bf984eSNoah Goldstein %z = or i8 %x, %ind 821f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 822f7bf984eSNoah Goldstein ret i1 %r 823f7bf984eSNoah Goldstein} 824f7bf984eSNoah Goldstein 825f7bf984eSNoah Goldsteindefine i1 @ushl_nonzero(i8 %xx, i8 %y, i8 %ind) { 826f7bf984eSNoah Goldstein; CHECK-LABEL: @ushl_nonzero( 827f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp ne i8 [[XX:%.*]], 0 828f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 829f1dfa493SNoah Goldstein; CHECK-NEXT: ret i1 false 830f7bf984eSNoah Goldstein; 831f7bf984eSNoah Goldstein %x_nz = icmp ne i8 %xx, 0 832f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_nz) 833f7bf984eSNoah Goldstein %x = call i8 @llvm.ushl.sat.i8(i8 %xx, i8 %y) 834f7bf984eSNoah Goldstein %z = or i8 %x, %ind 835f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 836f7bf984eSNoah Goldstein ret i1 %r 837f7bf984eSNoah Goldstein} 838f7bf984eSNoah Goldstein 839f7bf984eSNoah Goldsteindefine i1 @ushl_nonzero_fail_x_maybe_z(i8 %xx, i8 %y, i8 %ind) { 840f7bf984eSNoah Goldstein; CHECK-LABEL: @ushl_nonzero_fail_x_maybe_z( 841f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.ushl.sat.i8(i8 [[XX:%.*]], i8 [[Y:%.*]]) 842f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 843f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 844f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 845f7bf984eSNoah Goldstein; 846f7bf984eSNoah Goldstein %x = call i8 @llvm.ushl.sat.i8(i8 %xx, i8 %y) 847f7bf984eSNoah Goldstein %z = or i8 %x, %ind 848f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 849f7bf984eSNoah Goldstein ret i1 %r 850f7bf984eSNoah Goldstein} 851f7bf984eSNoah Goldstein 852f7bf984eSNoah Goldsteindefine i1 @ssub_sat_nonzero(i8 %xx, i8 %yy, i8 %ind) { 853f7bf984eSNoah Goldstein; CHECK-LABEL: @ssub_sat_nonzero( 854461ded46SNoah Goldstein; CHECK-NEXT: ret i1 false 855f7bf984eSNoah Goldstein; 856f7bf984eSNoah Goldstein %xa = and i8 %xx, 191 857f7bf984eSNoah Goldstein %yo = or i8 %yy, 64 858f7bf984eSNoah Goldstein %x = call i8 @llvm.ssub.sat.i8(i8 %xa, i8 %yo) 859f7bf984eSNoah Goldstein %z = or i8 %x, %ind 860f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 861f7bf984eSNoah Goldstein ret i1 %r 862f7bf984eSNoah Goldstein} 863f7bf984eSNoah Goldstein 864f7bf984eSNoah Goldsteindefine i1 @ssub_sat_nonzero_ne_known_bits_fail_overlap(i8 %xx, i8 %yy, i8 %ind) { 865f7bf984eSNoah Goldstein; CHECK-LABEL: @ssub_sat_nonzero_ne_known_bits_fail_overlap( 866f7bf984eSNoah Goldstein; CHECK-NEXT: [[XA:%.*]] = and i8 [[XX:%.*]], -64 867f7bf984eSNoah Goldstein; CHECK-NEXT: [[YO:%.*]] = or i8 [[YY:%.*]], 64 868f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[XA]], i8 [[YO]]) 869f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 870f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 871f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 872f7bf984eSNoah Goldstein; 873f7bf984eSNoah Goldstein %xa = and i8 %xx, 192 874f7bf984eSNoah Goldstein %yo = or i8 %yy, 64 875f7bf984eSNoah Goldstein %x = call i8 @llvm.ssub.sat.i8(i8 %xa, i8 %yo) 876f7bf984eSNoah Goldstein %z = or i8 %x, %ind 877f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 878f7bf984eSNoah Goldstein ret i1 %r 879f7bf984eSNoah Goldstein} 880f7bf984eSNoah Goldstein 881f7bf984eSNoah Goldsteindefine i1 @usub_sat_nonzero(i8 %xx, i8 %yy, i8 %ind) { 882f7bf984eSNoah Goldstein; CHECK-LABEL: @usub_sat_nonzero( 883f7bf984eSNoah Goldstein; CHECK-NEXT: [[Y_ULT_31:%.*]] = icmp ult i8 [[YY:%.*]], 31 884f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[Y_ULT_31]]) 885f7bf984eSNoah Goldstein; CHECK-NEXT: [[XO:%.*]] = or i8 [[XX:%.*]], 34 886f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[XO]], i8 [[YY]]) 887f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 888f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 889f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 890f7bf984eSNoah Goldstein; 891f7bf984eSNoah Goldstein %y_ult_31 = icmp ult i8 %yy, 31 892f7bf984eSNoah Goldstein call void @llvm.assume(i1 %y_ult_31) 893f7bf984eSNoah Goldstein %xo = or i8 %xx, 34 894f7bf984eSNoah Goldstein %x = call i8 @llvm.usub.sat.i8(i8 %xo, i8 %yy) 895f7bf984eSNoah Goldstein %z = or i8 %x, %ind 896f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 897f7bf984eSNoah Goldstein ret i1 %r 898f7bf984eSNoah Goldstein} 899f7bf984eSNoah Goldstein 900f7bf984eSNoah Goldsteindefine i1 @usub_sat_nonzero_fail(i8 %xx, i8 %yy, i8 %ind) { 901f7bf984eSNoah Goldstein; CHECK-LABEL: @usub_sat_nonzero_fail( 902f7bf984eSNoah Goldstein; CHECK-NEXT: [[XA:%.*]] = and i8 [[XX:%.*]], 16 903f7bf984eSNoah Goldstein; CHECK-NEXT: [[YO:%.*]] = or i8 [[YY:%.*]], 7 904f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[XA]], i8 [[YO]]) 905f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 906f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 907f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 908f7bf984eSNoah Goldstein; 909f7bf984eSNoah Goldstein %xa = and i8 %xx, 16 910f7bf984eSNoah Goldstein %yo = or i8 %yy, 7 911f7bf984eSNoah Goldstein %x = call i8 @llvm.usub.sat.i8(i8 %xa, i8 %yo) 912f7bf984eSNoah Goldstein %z = or i8 %x, %ind 913f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 914f7bf984eSNoah Goldstein ret i1 %r 915f7bf984eSNoah Goldstein} 916f7bf984eSNoah Goldstein 917f7bf984eSNoah Goldsteindefine i1 @sadd_sat_nonzero(i8 %xx, i8 %yy, i8 %ind) { 918f7bf984eSNoah Goldstein; CHECK-LABEL: @sadd_sat_nonzero( 919f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_STRICT_POS:%.*]] = icmp sgt i8 [[XX:%.*]], 0 920f7bf984eSNoah Goldstein; CHECK-NEXT: [[Y_POS:%.*]] = icmp sge i8 [[YY:%.*]], 0 921f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_STRICT_POS]]) 922f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[Y_POS]]) 923167ecdaaSNoah Goldstein; CHECK-NEXT: ret i1 false 924f7bf984eSNoah Goldstein; 925f7bf984eSNoah Goldstein %x_strict_pos = icmp sgt i8 %xx, 0 926f7bf984eSNoah Goldstein %y_pos = icmp sge i8 %yy, 0 927f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_strict_pos) 928f7bf984eSNoah Goldstein call void @llvm.assume(i1 %y_pos) 929f7bf984eSNoah Goldstein %x = call i8 @llvm.sadd.sat.i8(i8 %xx, i8 %yy) 930f7bf984eSNoah Goldstein %z = or i8 %x, %ind 931f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 932f7bf984eSNoah Goldstein ret i1 %r 933f7bf984eSNoah Goldstein} 934f7bf984eSNoah Goldstein 935f7bf984eSNoah Goldsteindefine i1 @sadd_sat_nonzero_fail_maybe_zz(i8 %xx, i8 %yy, i8 %ind) { 936f7bf984eSNoah Goldstein; CHECK-LABEL: @sadd_sat_nonzero_fail_maybe_zz( 937f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_POS:%.*]] = icmp sge i8 [[XX:%.*]], 0 938f7bf984eSNoah Goldstein; CHECK-NEXT: [[Y_POS:%.*]] = icmp sge i8 [[YY:%.*]], 0 939f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_POS]]) 940f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[Y_POS]]) 941f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[XX]], i8 [[YY]]) 942f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 943f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 944f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 945f7bf984eSNoah Goldstein; 946f7bf984eSNoah Goldstein %x_pos = icmp sge i8 %xx, 0 947f7bf984eSNoah Goldstein %y_pos = icmp sge i8 %yy, 0 948f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_pos) 949f7bf984eSNoah Goldstein call void @llvm.assume(i1 %y_pos) 950f7bf984eSNoah Goldstein %x = call i8 @llvm.sadd.sat.i8(i8 %xx, i8 %yy) 951f7bf984eSNoah Goldstein %z = or i8 %x, %ind 952f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 953f7bf984eSNoah Goldstein ret i1 %r 954f7bf984eSNoah Goldstein} 955f7bf984eSNoah Goldstein 956f7bf984eSNoah Goldsteindefine i1 @umax_nonzero(i8 %xx, i8 %yy, i8 %ind) { 957f7bf984eSNoah Goldstein; CHECK-LABEL: @umax_nonzero( 958f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp ne i8 [[XX:%.*]], 0 959f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 960883daa7aSNoah Goldstein; CHECK-NEXT: ret i1 false 961f7bf984eSNoah Goldstein; 962f7bf984eSNoah Goldstein %x_nz = icmp ne i8 %xx, 0 963f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_nz) 964f7bf984eSNoah Goldstein %x = call i8 @llvm.umax.i8(i8 %xx, i8 %yy) 965f7bf984eSNoah Goldstein %z = or i8 %x, %ind 966f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 967f7bf984eSNoah Goldstein ret i1 %r 968f7bf984eSNoah Goldstein} 969f7bf984eSNoah Goldstein 970f7bf984eSNoah Goldsteindefine i1 @umax_nonzero_fail_x_maybe_z(i8 %xx, i8 %yy, i8 %ind) { 971f7bf984eSNoah Goldstein; CHECK-LABEL: @umax_nonzero_fail_x_maybe_z( 972f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp sge i8 [[XX:%.*]], 0 973f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 974f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.umax.i8(i8 [[XX]], i8 [[YY:%.*]]) 975f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 976f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 977f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 978f7bf984eSNoah Goldstein; 979f7bf984eSNoah Goldstein %x_nz = icmp sge i8 %xx, 0 980f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_nz) 981f7bf984eSNoah Goldstein %x = call i8 @llvm.umax.i8(i8 %xx, i8 %yy) 982f7bf984eSNoah Goldstein %z = or i8 %x, %ind 983f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 984f7bf984eSNoah Goldstein ret i1 %r 985f7bf984eSNoah Goldstein} 986f7bf984eSNoah Goldstein 987f7bf984eSNoah Goldsteindefine i1 @umin_nonzero(i8 %xx, i8 %yy, i8 %ind) { 988f7bf984eSNoah Goldstein; CHECK-LABEL: @umin_nonzero( 989f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp ne i8 [[XX:%.*]], 0 990f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 991f7bf984eSNoah Goldstein; CHECK-NEXT: [[Y_NZ:%.*]] = icmp ne i8 [[YY:%.*]], 0 992f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[Y_NZ]]) 993e78c30a1SNoah Goldstein; CHECK-NEXT: ret i1 false 994f7bf984eSNoah Goldstein; 995f7bf984eSNoah Goldstein %x_nz = icmp ne i8 %xx, 0 996f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_nz) 997f7bf984eSNoah Goldstein %y_nz = icmp ne i8 %yy, 0 998f7bf984eSNoah Goldstein call void @llvm.assume(i1 %y_nz) 999f7bf984eSNoah Goldstein %x = call i8 @llvm.umin.i8(i8 %xx, i8 %yy) 1000f7bf984eSNoah Goldstein %z = or i8 %x, %ind 1001f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 1002f7bf984eSNoah Goldstein ret i1 %r 1003f7bf984eSNoah Goldstein} 1004f7bf984eSNoah Goldstein 1005f7bf984eSNoah Goldsteindefine i1 @umin_nonzero_fail_y_maybe_z(i8 %xx, i8 %yy, i8 %ind) { 1006f7bf984eSNoah Goldstein; CHECK-LABEL: @umin_nonzero_fail_y_maybe_z( 1007f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp ne i8 [[XX:%.*]], 0 1008f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 1009f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.umin.i8(i8 [[XX]], i8 [[YY:%.*]]) 1010f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 1011f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 1012f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 1013f7bf984eSNoah Goldstein; 1014f7bf984eSNoah Goldstein %x_nz = icmp ne i8 %xx, 0 1015f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_nz) 1016f7bf984eSNoah Goldstein %x = call i8 @llvm.umin.i8(i8 %xx, i8 %yy) 1017f7bf984eSNoah Goldstein %z = or i8 %x, %ind 1018f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 1019f7bf984eSNoah Goldstein ret i1 %r 1020f7bf984eSNoah Goldstein} 1021f7bf984eSNoah Goldstein 1022f7bf984eSNoah Goldsteindefine i1 @smin_nonzero(i8 %xx, i8 %yy, i8 %ind) { 1023f7bf984eSNoah Goldstein; CHECK-LABEL: @smin_nonzero( 1024f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp ne i8 [[XX:%.*]], 0 1025f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 1026f7bf984eSNoah Goldstein; CHECK-NEXT: [[Y_NZ:%.*]] = icmp ne i8 [[YY:%.*]], 0 1027f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[Y_NZ]]) 1028e78c30a1SNoah Goldstein; CHECK-NEXT: ret i1 false 1029f7bf984eSNoah Goldstein; 1030f7bf984eSNoah Goldstein %x_nz = icmp ne i8 %xx, 0 1031f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_nz) 1032f7bf984eSNoah Goldstein %y_nz = icmp ne i8 %yy, 0 1033f7bf984eSNoah Goldstein call void @llvm.assume(i1 %y_nz) 1034f7bf984eSNoah Goldstein %x = call i8 @llvm.umin.i8(i8 %xx, i8 %yy) 1035f7bf984eSNoah Goldstein %z = or i8 %x, %ind 1036f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 1037f7bf984eSNoah Goldstein ret i1 %r 1038f7bf984eSNoah Goldstein} 1039f7bf984eSNoah Goldstein 1040f7bf984eSNoah Goldsteindefine i1 @smin_nonzero_neg_arg(i8 %xx, i8 %yy, i8 %ind) { 1041f7bf984eSNoah Goldstein; CHECK-LABEL: @smin_nonzero_neg_arg( 1042f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_NEG:%.*]] = icmp slt i8 [[XX:%.*]], 0 1043f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NEG]]) 1044f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 false 1045f7bf984eSNoah Goldstein; 1046f7bf984eSNoah Goldstein %x_neg = icmp slt i8 %xx, 0 1047f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_neg) 1048f7bf984eSNoah Goldstein %x = call i8 @llvm.smin.i8(i8 %xx, i8 %yy) 1049f7bf984eSNoah Goldstein %z = or i8 %x, %ind 1050f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 1051f7bf984eSNoah Goldstein ret i1 %r 1052f7bf984eSNoah Goldstein} 1053f7bf984eSNoah Goldstein 1054f7bf984eSNoah Goldsteindefine i1 @smin_nonzero_fail_y_maybe_z(i8 %xx, i8 %yy, i8 %ind) { 1055f7bf984eSNoah Goldstein; CHECK-LABEL: @smin_nonzero_fail_y_maybe_z( 1056f7bf984eSNoah Goldstein; CHECK-NEXT: [[X_NZ:%.*]] = icmp sle i8 [[XX:%.*]], 0 1057f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]]) 1058f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.smin.i8(i8 [[XX]], i8 [[YY:%.*]]) 1059f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 1060f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 1061f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 1062f7bf984eSNoah Goldstein; 1063f7bf984eSNoah Goldstein %x_nz = icmp sle i8 %xx, 0 1064f7bf984eSNoah Goldstein call void @llvm.assume(i1 %x_nz) 1065f7bf984eSNoah Goldstein %x = call i8 @llvm.smin.i8(i8 %xx, i8 %yy) 1066f7bf984eSNoah Goldstein %z = or i8 %x, %ind 1067f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 1068f7bf984eSNoah Goldstein ret i1 %r 1069f7bf984eSNoah Goldstein} 1070f7bf984eSNoah Goldstein 1071f7bf984eSNoah Goldsteindefine i1 @smax_nonzero_pos_arg(i8 %xx, i8 %yy, i8 %ind) { 1072f7bf984eSNoah Goldstein; CHECK-LABEL: @smax_nonzero_pos_arg( 1073d8403914SNoah Goldstein; CHECK-NEXT: ret i1 false 1074f7bf984eSNoah Goldstein; 1075f7bf984eSNoah Goldstein %ya = and i8 %yy, 127 1076f7bf984eSNoah Goldstein %yo = or i8 %ya, 1 1077f7bf984eSNoah Goldstein %x = call i8 @llvm.smax.i8(i8 %xx, i8 %yo) 1078f7bf984eSNoah Goldstein %z = or i8 %x, %ind 1079f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 1080f7bf984eSNoah Goldstein ret i1 %r 1081f7bf984eSNoah Goldstein} 1082f7bf984eSNoah Goldstein 1083f7bf984eSNoah Goldsteindefine i1 @smax_nonzero_pos_arg_fail_nonstrict_pos(i8 %xx, i8 %yy, i8 %ind) { 1084f7bf984eSNoah Goldstein; CHECK-LABEL: @smax_nonzero_pos_arg_fail_nonstrict_pos( 1085f7bf984eSNoah Goldstein; CHECK-NEXT: [[Y_POS:%.*]] = icmp sge i8 [[YY:%.*]], 0 1086f7bf984eSNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[Y_POS]]) 1087f7bf984eSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.smax.i8(i8 [[XX:%.*]], i8 [[YY]]) 1088f7bf984eSNoah Goldstein; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]] 1089f7bf984eSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0 1090f7bf984eSNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 1091f7bf984eSNoah Goldstein; 1092f7bf984eSNoah Goldstein %y_pos = icmp sge i8 %yy, 0 1093f7bf984eSNoah Goldstein call void @llvm.assume(i1 %y_pos) 1094f7bf984eSNoah Goldstein %x = call i8 @llvm.smax.i8(i8 %xx, i8 %yy) 1095f7bf984eSNoah Goldstein %z = or i8 %x, %ind 1096f7bf984eSNoah Goldstein %r = icmp eq i8 %z, 0 1097f7bf984eSNoah Goldstein ret i1 %r 1098f7bf984eSNoah Goldstein} 10997f82f108SNoah Goldstein 11007f82f108SNoah Goldsteindefine i1 @mul_nonzero_contains_nonzero_mul(i8 %x, i8 %y) { 11017f82f108SNoah Goldstein; CHECK-LABEL: @mul_nonzero_contains_nonzero_mul( 1102774ecc20SNoah Goldstein; CHECK-NEXT: ret i1 true 11037f82f108SNoah Goldstein; 11047f82f108SNoah Goldstein %xx = or i8 %x, 16 11057f82f108SNoah Goldstein %yy = or i8 %y, 8 11067f82f108SNoah Goldstein %xy = mul i8 %xx, %yy 11077f82f108SNoah Goldstein %nz = icmp ne i8 %xy, 0 11087f82f108SNoah Goldstein ret i1 %nz 11097f82f108SNoah Goldstein} 11107f82f108SNoah Goldstein 11117f82f108SNoah Goldsteindefine i1 @src_mul_maybe_zero_no_nonzero_mul(i8 %x, i8 %y) { 11127f82f108SNoah Goldstein; CHECK-LABEL: @src_mul_maybe_zero_no_nonzero_mul( 11137f82f108SNoah Goldstein; CHECK-NEXT: [[XX:%.*]] = or i8 [[X:%.*]], 96 11147f82f108SNoah Goldstein; CHECK-NEXT: [[YY:%.*]] = or i8 [[Y:%.*]], 8 11157f82f108SNoah Goldstein; CHECK-NEXT: [[XY:%.*]] = mul i8 [[XX]], [[YY]] 11167f82f108SNoah Goldstein; CHECK-NEXT: [[NZ:%.*]] = icmp ne i8 [[XY]], 0 11177f82f108SNoah Goldstein; CHECK-NEXT: ret i1 [[NZ]] 11187f82f108SNoah Goldstein; 11197f82f108SNoah Goldstein %xx = or i8 %x, 96 11207f82f108SNoah Goldstein %yy = or i8 %y, 8 11217f82f108SNoah Goldstein %xy = mul i8 %xx, %yy 11227f82f108SNoah Goldstein %nz = icmp ne i8 %xy, 0 11237f82f108SNoah Goldstein ret i1 %nz 11247f82f108SNoah Goldstein} 1125d0b4ed9aSNoah Goldstein 1126d0b4ed9aSNoah Goldsteindefine i1 @sdiv_known_non_zero(i8 %x, i8 %y) { 1127d0b4ed9aSNoah Goldstein; CHECK-LABEL: @sdiv_known_non_zero( 1128846ff921SNoah Goldstein; CHECK-NEXT: ret i1 true 1129d0b4ed9aSNoah Goldstein; 1130d0b4ed9aSNoah Goldstein %xx0 = or i8 %x, 135 1131d0b4ed9aSNoah Goldstein %xx = and i8 %xx0, -2 1132d0b4ed9aSNoah Goldstein %xy = sdiv i8 %xx, -2 1133d0b4ed9aSNoah Goldstein %nz = icmp ne i8 %xy, 0 1134d0b4ed9aSNoah Goldstein ret i1 %nz 1135d0b4ed9aSNoah Goldstein} 1136d0b4ed9aSNoah Goldstein 1137d0b4ed9aSNoah Goldsteindefine i1 @sdiv_known_non_zero2(i8 %x, i8 %y) { 1138d0b4ed9aSNoah Goldstein; CHECK-LABEL: @sdiv_known_non_zero2( 1139846ff921SNoah Goldstein; CHECK-NEXT: ret i1 true 1140d0b4ed9aSNoah Goldstein; 1141d0b4ed9aSNoah Goldstein %xx0 = or i8 %x, 15 1142d0b4ed9aSNoah Goldstein %xx = and i8 %xx0, -4 1143d0b4ed9aSNoah Goldstein %yy = and i8 %y, 3 1144d0b4ed9aSNoah Goldstein %xy = sdiv i8 %xx, %yy 1145d0b4ed9aSNoah Goldstein %nz = icmp ne i8 %xy, 0 1146d0b4ed9aSNoah Goldstein ret i1 %nz 1147d0b4ed9aSNoah Goldstein} 1148d0b4ed9aSNoah Goldstein 1149d0b4ed9aSNoah Goldsteindefine i1 @sdiv_known_non_zero_fail(i8 %x, i8 %y) { 1150d0b4ed9aSNoah Goldstein; CHECK-LABEL: @sdiv_known_non_zero_fail( 1151d0b4ed9aSNoah Goldstein; CHECK-NEXT: [[XX:%.*]] = or i8 [[X:%.*]], 15 1152d0b4ed9aSNoah Goldstein; CHECK-NEXT: [[YY:%.*]] = and i8 [[Y:%.*]], 3 1153d0b4ed9aSNoah Goldstein; CHECK-NEXT: [[XY:%.*]] = sdiv i8 [[XX]], [[YY]] 1154d0b4ed9aSNoah Goldstein; CHECK-NEXT: [[NZ:%.*]] = icmp ne i8 [[XY]], 0 1155d0b4ed9aSNoah Goldstein; CHECK-NEXT: ret i1 [[NZ]] 1156d0b4ed9aSNoah Goldstein; 1157d0b4ed9aSNoah Goldstein %xx = or i8 %x, 15 1158d0b4ed9aSNoah Goldstein %yy = and i8 %y, 3 1159d0b4ed9aSNoah Goldstein %xy = sdiv i8 %xx, %yy 1160d0b4ed9aSNoah Goldstein %nz = icmp ne i8 %xy, 0 1161d0b4ed9aSNoah Goldstein ret i1 %nz 1162d0b4ed9aSNoah Goldstein} 11639427fce6SNoah Goldstein 11649427fce6SNoah Goldsteindefine <2 x i1> @cmp_excludes_zero_with_nonsplat_vec(<2 x i8> %a, <2 x i8> %b) { 11659427fce6SNoah Goldstein; CHECK-LABEL: @cmp_excludes_zero_with_nonsplat_vec( 1166dfda65c8SNoah Goldstein; CHECK-NEXT: ret <2 x i1> zeroinitializer 11679427fce6SNoah Goldstein; 11689427fce6SNoah Goldstein %c = icmp sge <2 x i8> %a, <i8 1, i8 4> 11699427fce6SNoah Goldstein %s = select <2 x i1> %c, <2 x i8> %a, <2 x i8> <i8 4, i8 5> 11709427fce6SNoah Goldstein %and = or <2 x i8> %s, %b 11719427fce6SNoah Goldstein %r = icmp eq <2 x i8> %and, zeroinitializer 11729427fce6SNoah Goldstein ret <2 x i1> %r 11739427fce6SNoah Goldstein} 11749427fce6SNoah Goldstein 11759427fce6SNoah Goldsteindefine <2 x i1> @cmp_excludes_zero_with_nonsplat_vec_wundef(<2 x i8> %a, <2 x i8> %b) { 11769427fce6SNoah Goldstein; CHECK-LABEL: @cmp_excludes_zero_with_nonsplat_vec_wundef( 11779427fce6SNoah Goldstein; CHECK-NEXT: [[C:%.*]] = icmp sge <2 x i8> [[A:%.*]], <i8 1, i8 undef> 11789427fce6SNoah Goldstein; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[C]], <2 x i8> [[A]], <2 x i8> <i8 4, i8 5> 11799427fce6SNoah Goldstein; CHECK-NEXT: [[AND:%.*]] = or <2 x i8> [[S]], [[B:%.*]] 11809427fce6SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[AND]], zeroinitializer 11819427fce6SNoah Goldstein; CHECK-NEXT: ret <2 x i1> [[R]] 11829427fce6SNoah Goldstein; 11839427fce6SNoah Goldstein %c = icmp sge <2 x i8> %a, <i8 1, i8 undef> 11849427fce6SNoah Goldstein %s = select <2 x i1> %c, <2 x i8> %a, <2 x i8> <i8 4, i8 5> 11859427fce6SNoah Goldstein %and = or <2 x i8> %s, %b 11869427fce6SNoah Goldstein %r = icmp eq <2 x i8> %and, zeroinitializer 11879427fce6SNoah Goldstein ret <2 x i1> %r 11889427fce6SNoah Goldstein} 11899427fce6SNoah Goldstein 11909427fce6SNoah Goldsteindefine <2 x i1> @cmp_excludes_zero_with_nonsplat_vec_wpoison(<2 x i8> %a, <2 x i8> %b) { 11919427fce6SNoah Goldstein; CHECK-LABEL: @cmp_excludes_zero_with_nonsplat_vec_wpoison( 11929427fce6SNoah Goldstein; CHECK-NEXT: [[C:%.*]] = icmp sge <2 x i8> [[A:%.*]], <i8 1, i8 poison> 11939427fce6SNoah Goldstein; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[C]], <2 x i8> [[A]], <2 x i8> <i8 4, i8 5> 11949427fce6SNoah Goldstein; CHECK-NEXT: [[AND:%.*]] = or <2 x i8> [[S]], [[B:%.*]] 11959427fce6SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[AND]], zeroinitializer 11969427fce6SNoah Goldstein; CHECK-NEXT: ret <2 x i1> [[R]] 11979427fce6SNoah Goldstein; 11989427fce6SNoah Goldstein %c = icmp sge <2 x i8> %a, <i8 1, i8 poison> 11999427fce6SNoah Goldstein %s = select <2 x i1> %c, <2 x i8> %a, <2 x i8> <i8 4, i8 5> 12009427fce6SNoah Goldstein %and = or <2 x i8> %s, %b 12019427fce6SNoah Goldstein %r = icmp eq <2 x i8> %and, zeroinitializer 12029427fce6SNoah Goldstein ret <2 x i1> %r 12039427fce6SNoah Goldstein} 12049427fce6SNoah Goldstein 12059427fce6SNoah Goldsteindefine <2 x i1> @cmp_excludes_zero_with_nonsplat_vec_fail(<2 x i8> %a, <2 x i8> %b) { 12069427fce6SNoah Goldstein; CHECK-LABEL: @cmp_excludes_zero_with_nonsplat_vec_fail( 12079427fce6SNoah Goldstein; CHECK-NEXT: [[C:%.*]] = icmp sge <2 x i8> [[A:%.*]], <i8 0, i8 4> 12089427fce6SNoah Goldstein; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[C]], <2 x i8> [[A]], <2 x i8> <i8 4, i8 5> 12099427fce6SNoah Goldstein; CHECK-NEXT: [[AND:%.*]] = or <2 x i8> [[S]], [[B:%.*]] 12109427fce6SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[AND]], zeroinitializer 12119427fce6SNoah Goldstein; CHECK-NEXT: ret <2 x i1> [[R]] 12129427fce6SNoah Goldstein; 12139427fce6SNoah Goldstein %c = icmp sge <2 x i8> %a, <i8 0, i8 4> 12149427fce6SNoah Goldstein %s = select <2 x i1> %c, <2 x i8> %a, <2 x i8> <i8 4, i8 5> 12159427fce6SNoah Goldstein %and = or <2 x i8> %s, %b 12169427fce6SNoah Goldstein %r = icmp eq <2 x i8> %and, zeroinitializer 12179427fce6SNoah Goldstein ret <2 x i1> %r 12189427fce6SNoah Goldstein} 12199427fce6SNoah Goldstein 12207c1d8c74SNikita Popovdefine i1 @sub_via_non_eq(i8 %x, i8 %y) { 12217c1d8c74SNikita Popov; CHECK-LABEL: @sub_via_non_eq( 12227c1d8c74SNikita Popov; CHECK-NEXT: [[NE:%.*]] = icmp ne i8 [[X:%.*]], 0 12237c1d8c74SNikita Popov; CHECK-NEXT: call void @llvm.assume(i1 [[NE]]) 122433750468SNikita Popov; CHECK-NEXT: ret i1 false 12257c1d8c74SNikita Popov; 12267c1d8c74SNikita Popov %ne = icmp ne i8 %x, 0 12277c1d8c74SNikita Popov call void @llvm.assume(i1 %ne) 12287c1d8c74SNikita Popov %shl = shl nuw i8 %x, 3 12297c1d8c74SNikita Popov %sub = sub i8 %x, %shl 12307c1d8c74SNikita Popov %cmp = icmp eq i8 %sub, 0 12317c1d8c74SNikita Popov ret i1 %cmp 12327c1d8c74SNikita Popov} 123364987c64Sbipmis 123464987c64Sbipmis; Test mismatch of ptrtoints type and pointer size 123564987c64Sbipmisdefine i1 @recursiveGEP_orcmp_truncPtr(ptr %val1, i32 %val2) { 123664987c64Sbipmis; CHECK-LABEL: @recursiveGEP_orcmp_truncPtr( 123764987c64Sbipmis; CHECK-NEXT: entry: 123864987c64Sbipmis; CHECK-NEXT: br label [[WHILE_COND_I:%.*]] 123964987c64Sbipmis; CHECK: while.cond.i: 124064987c64Sbipmis; CHECK-NEXT: [[A_PN_I:%.*]] = phi ptr [ [[TEST_0_I:%.*]], [[WHILE_COND_I]] ], [ [[VAL1:%.*]], [[ENTRY:%.*]] ] 124164987c64Sbipmis; CHECK-NEXT: [[TEST_0_I]] = getelementptr inbounds i8, ptr [[A_PN_I]], i64 1 124264987c64Sbipmis; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[TEST_0_I]], align 2 124364987c64Sbipmis; CHECK-NEXT: [[CMP3_NOT_I:%.*]] = icmp eq i8 [[TMP0]], 0 124464987c64Sbipmis; CHECK-NEXT: br i1 [[CMP3_NOT_I]], label [[WHILE_END_I:%.*]], label [[WHILE_COND_I]] 124564987c64Sbipmis; CHECK: while.end.i: 124664987c64Sbipmis; CHECK-NEXT: [[SUB_PTR_LHS_CAST_I:%.*]] = ptrtoint ptr [[TEST_0_I]] to i32 124764987c64Sbipmis; CHECK-NEXT: [[SUB_PTR_RHS_CAST_I:%.*]] = ptrtoint ptr [[VAL1]] to i32 124864987c64Sbipmis; CHECK-NEXT: [[SUB_PTR_SUB_I:%.*]] = sub i32 [[SUB_PTR_LHS_CAST_I]], [[SUB_PTR_RHS_CAST_I]] 124964987c64Sbipmis; CHECK-NEXT: [[ORVAL:%.*]] = or i32 [[VAL2:%.*]], [[SUB_PTR_SUB_I]] 125064987c64Sbipmis; CHECK-NEXT: [[BOOL:%.*]] = icmp eq i32 [[ORVAL]], 0 125164987c64Sbipmis; CHECK-NEXT: ret i1 [[BOOL]] 125264987c64Sbipmis; 125364987c64Sbipmisentry: 125464987c64Sbipmis br label %while.cond.i 125564987c64Sbipmis 125664987c64Sbipmiswhile.cond.i: 125764987c64Sbipmis %a.pn.i = phi ptr [ %test.0.i, %while.cond.i ], [ %val1, %entry ] 125864987c64Sbipmis %test.0.i = getelementptr inbounds i8, ptr %a.pn.i, i64 1 125964987c64Sbipmis %0 = load i8, ptr %test.0.i, align 2 126064987c64Sbipmis %cmp3.not.i = icmp eq i8 %0, 0 126164987c64Sbipmis br i1 %cmp3.not.i, label %while.end.i, label %while.cond.i 126264987c64Sbipmis 126364987c64Sbipmiswhile.end.i: 126464987c64Sbipmis %sub.ptr.lhs.cast.i = ptrtoint ptr %test.0.i to i32 126564987c64Sbipmis %sub.ptr.rhs.cast.i = ptrtoint ptr %val1 to i32 126664987c64Sbipmis %sub.ptr.sub.i = sub i32 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i 126764987c64Sbipmis %orval = or i32 %val2, %sub.ptr.sub.i 126864987c64Sbipmis %bool = icmp eq i32 %orval, 0 126964987c64Sbipmis ret i1 %bool 127064987c64Sbipmis} 1271d8e1b451SCraig Topper 1272d8e1b451SCraig Topperdefine i1 @check_get_vector_length(i32 %x, i32 %y) { 1273d8e1b451SCraig Topper; CHECK-LABEL: @check_get_vector_length( 1274d8e1b451SCraig Topper; CHECK-NEXT: [[NE:%.*]] = icmp ne i32 [[X:%.*]], 0 1275d8e1b451SCraig Topper; CHECK-NEXT: br i1 [[NE]], label [[TRUE:%.*]], label [[FALSE:%.*]] 1276d8e1b451SCraig Topper; CHECK: true: 1277d8e1b451SCraig Topper; CHECK-NEXT: [[Z:%.*]] = call i32 @llvm.experimental.get.vector.length.i32(i32 [[X]], i32 1, i1 true) 1278d8e1b451SCraig Topper; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt i32 [[Z]], [[Y:%.*]] 1279d8e1b451SCraig Topper; CHECK-NEXT: ret i1 [[CMP0]] 1280d8e1b451SCraig Topper; CHECK: false: 1281d8e1b451SCraig Topper; CHECK-NEXT: ret i1 [[NE]] 1282d8e1b451SCraig Topper; 1283d8e1b451SCraig Topper %ne = icmp ne i32 %x, 0 1284d8e1b451SCraig Topper br i1 %ne, label %true, label %false 1285d8e1b451SCraig Toppertrue: 1286d8e1b451SCraig Topper %z = call i32 @llvm.experimental.get.vector.length.i32(i32 %x, i32 1, i1 true) 1287d8e1b451SCraig Topper %cmp0 = icmp ugt i32 %z, %y 1288d8e1b451SCraig Topper %cmp1 = icmp eq i32 %y, 0 1289d8e1b451SCraig Topper %r = or i1 %cmp0, %cmp1 1290d8e1b451SCraig Topper ret i1 %r 1291d8e1b451SCraig Topperfalse: 1292d8e1b451SCraig Topper ret i1 %ne 1293d8e1b451SCraig Topper} 12940e768186SNikita Popov 12950e768186SNikita Popovdefine <2 x i1> @range_metadata_vec(ptr %p, <2 x i32> %x) { 12960e768186SNikita Popov; CHECK-LABEL: @range_metadata_vec( 1297*38fffa63SPaul Walker; CHECK-NEXT: ret <2 x i1> splat (i1 true) 12980e768186SNikita Popov; 12990e768186SNikita Popov %v = load <2 x i32>, ptr %p, !range !{i32 1, i32 100} 13000e768186SNikita Popov %or = or <2 x i32> %v, %x 13010e768186SNikita Popov %cmp = icmp ne <2 x i32> %or, zeroinitializer 13020e768186SNikita Popov ret <2 x i1> %cmp 13030e768186SNikita Popov} 13040e768186SNikita Popov 1305e66cfebbSAndreas Jonsondefine i1 @range_attr(i8 range(i8 1, 0) %x, i8 %y) { 1306e66cfebbSAndreas Jonson; CHECK-LABEL: @range_attr( 1307e66cfebbSAndreas Jonson; CHECK-NEXT: ret i1 false 1308e66cfebbSAndreas Jonson; 1309e66cfebbSAndreas Jonson %or = or i8 %y, %x 1310e66cfebbSAndreas Jonson %cmp = icmp eq i8 %or, 0 1311e66cfebbSAndreas Jonson ret i1 %cmp 1312e66cfebbSAndreas Jonson} 1313e66cfebbSAndreas Jonson 1314e66cfebbSAndreas Jonsondefine i1 @neg_range_attr(i8 range(i8 -1, 1) %x, i8 %y) { 1315e66cfebbSAndreas Jonson; CHECK-LABEL: @neg_range_attr( 1316b3ca9c30SNoah Goldstein; CHECK-NEXT: [[OR:%.*]] = or i8 [[Y:%.*]], [[X:%.*]] 1317b3ca9c30SNoah Goldstein; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[OR]], 0 1318e66cfebbSAndreas Jonson; CHECK-NEXT: ret i1 [[CMP]] 1319e66cfebbSAndreas Jonson; 1320e66cfebbSAndreas Jonson %or = or i8 %y, %x 1321e66cfebbSAndreas Jonson %cmp = icmp eq i8 %or, 0 1322e66cfebbSAndreas Jonson ret i1 %cmp 1323e66cfebbSAndreas Jonson} 1324e66cfebbSAndreas Jonson 1325e66cfebbSAndreas Jonsondeclare range(i8 1, 0) i8 @returns_non_zero_range_helper() 1326e66cfebbSAndreas Jonsondeclare range(i8 -1, 1) i8 @returns_contain_zero_range_helper() 1327e66cfebbSAndreas Jonson 1328e66cfebbSAndreas Jonsondefine i1 @range_return(i8 %y) { 1329e66cfebbSAndreas Jonson; CHECK-LABEL: @range_return( 1330b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @returns_non_zero_range_helper() 1331e66cfebbSAndreas Jonson; CHECK-NEXT: ret i1 false 1332e66cfebbSAndreas Jonson; 1333e66cfebbSAndreas Jonson %x = call i8 @returns_non_zero_range_helper() 1334e66cfebbSAndreas Jonson %or = or i8 %y, %x 1335e66cfebbSAndreas Jonson %cmp = icmp eq i8 %or, 0 1336e66cfebbSAndreas Jonson ret i1 %cmp 1337e66cfebbSAndreas Jonson} 1338e66cfebbSAndreas Jonson 1339e66cfebbSAndreas Jonsondefine i1 @neg_range_return(i8 %y) { 1340e66cfebbSAndreas Jonson; CHECK-LABEL: @neg_range_return( 1341b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call i8 @returns_contain_zero_range_helper() 1342b3ca9c30SNoah Goldstein; CHECK-NEXT: [[OR:%.*]] = or i8 [[Y:%.*]], [[X]] 1343e66cfebbSAndreas Jonson; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[OR]], 0 1344e66cfebbSAndreas Jonson; CHECK-NEXT: ret i1 [[CMP]] 1345e66cfebbSAndreas Jonson; 1346e66cfebbSAndreas Jonson %x = call i8 @returns_contain_zero_range_helper() 1347e66cfebbSAndreas Jonson %or = or i8 %y, %x 1348e66cfebbSAndreas Jonson %cmp = icmp eq i8 %or, 0 1349e66cfebbSAndreas Jonson ret i1 %cmp 1350e66cfebbSAndreas Jonson} 1351e66cfebbSAndreas Jonson 1352e66cfebbSAndreas Jonsondeclare i8 @returns_i8_helper() 1353e66cfebbSAndreas Jonson 1354e66cfebbSAndreas Jonsondefine i1 @range_call(i8 %y) { 1355e66cfebbSAndreas Jonson; CHECK-LABEL: @range_call( 1356b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call range(i8 1, 0) i8 @returns_i8_helper() 1357e66cfebbSAndreas Jonson; CHECK-NEXT: ret i1 false 1358e66cfebbSAndreas Jonson; 1359e66cfebbSAndreas Jonson %x = call range(i8 1, 0) i8 @returns_i8_helper() 1360e66cfebbSAndreas Jonson %or = or i8 %y, %x 1361e66cfebbSAndreas Jonson %cmp = icmp eq i8 %or, 0 1362e66cfebbSAndreas Jonson ret i1 %cmp 1363e66cfebbSAndreas Jonson} 1364e66cfebbSAndreas Jonson 1365e66cfebbSAndreas Jonsondefine i1 @neg_range_call(i8 %y) { 1366e66cfebbSAndreas Jonson; CHECK-LABEL: @neg_range_call( 1367b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call range(i8 -1, 1) i8 @returns_i8_helper() 1368b3ca9c30SNoah Goldstein; CHECK-NEXT: [[OR:%.*]] = or i8 [[Y:%.*]], [[X]] 1369e66cfebbSAndreas Jonson; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[OR]], 0 1370e66cfebbSAndreas Jonson; CHECK-NEXT: ret i1 [[CMP]] 1371e66cfebbSAndreas Jonson; 1372e66cfebbSAndreas Jonson %x = call range(i8 -1, 1) i8 @returns_i8_helper() 1373e66cfebbSAndreas Jonson %or = or i8 %y, %x 1374e66cfebbSAndreas Jonson %cmp = icmp eq i8 %or, 0 1375e66cfebbSAndreas Jonson ret i1 %cmp 1376e66cfebbSAndreas Jonson} 1377e66cfebbSAndreas Jonson 1378e66cfebbSAndreas Jonsondefine <2 x i1> @range_attr_vec(<2 x i8> range(i8 1, 0) %x, <2 x i8> %y) { 1379e66cfebbSAndreas Jonson; CHECK-LABEL: @range_attr_vec( 1380*38fffa63SPaul Walker; CHECK-NEXT: ret <2 x i1> splat (i1 true) 1381e66cfebbSAndreas Jonson; 1382e66cfebbSAndreas Jonson %or = or <2 x i8> %y, %x 1383e66cfebbSAndreas Jonson %cmp = icmp ne <2 x i8> %or, zeroinitializer 1384e66cfebbSAndreas Jonson ret <2 x i1> %cmp 1385e66cfebbSAndreas Jonson} 1386e66cfebbSAndreas Jonson 1387e66cfebbSAndreas Jonsondefine <2 x i1> @neg_range_attr_vec(<2 x i8> range(i8 -1, 1) %x, <2 x i8> %y) { 1388e66cfebbSAndreas Jonson; CHECK-LABEL: @neg_range_attr_vec( 1389e66cfebbSAndreas Jonson; CHECK-NEXT: [[OR:%.*]] = or <2 x i8> [[Y:%.*]], [[X:%.*]] 1390e66cfebbSAndreas Jonson; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i8> [[OR]], zeroinitializer 1391e66cfebbSAndreas Jonson; CHECK-NEXT: ret <2 x i1> [[CMP]] 1392e66cfebbSAndreas Jonson; 1393e66cfebbSAndreas Jonson %or = or <2 x i8> %y, %x 1394e66cfebbSAndreas Jonson %cmp = icmp ne <2 x i8> %or, zeroinitializer 1395e66cfebbSAndreas Jonson ret <2 x i1> %cmp 1396e66cfebbSAndreas Jonson} 1397e66cfebbSAndreas Jonson 1398e66cfebbSAndreas Jonsondeclare range(i8 1, 0) <2 x i8> @returns_non_zero_range_helper_vec() 1399e66cfebbSAndreas Jonsondeclare range(i8 -1, 1) <2 x i8> @returns_contain_zero_range_helper_vec() 1400e66cfebbSAndreas Jonson 1401e66cfebbSAndreas Jonsondefine <2 x i1> @range_return_vec(<2 x i8> %y) { 1402e66cfebbSAndreas Jonson; CHECK-LABEL: @range_return_vec( 1403b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call <2 x i8> @returns_non_zero_range_helper_vec() 1404*38fffa63SPaul Walker; CHECK-NEXT: ret <2 x i1> splat (i1 true) 1405e66cfebbSAndreas Jonson; 1406e66cfebbSAndreas Jonson %x = call <2 x i8> @returns_non_zero_range_helper_vec() 1407e66cfebbSAndreas Jonson %or = or <2 x i8> %y, %x 1408e66cfebbSAndreas Jonson %cmp = icmp ne <2 x i8> %or, zeroinitializer 1409e66cfebbSAndreas Jonson ret <2 x i1> %cmp 1410e66cfebbSAndreas Jonson} 1411e66cfebbSAndreas Jonson 1412e66cfebbSAndreas Jonsondefine <2 x i1> @neg_range_return_vec(<2 x i8> %y) { 1413e66cfebbSAndreas Jonson; CHECK-LABEL: @neg_range_return_vec( 1414b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call <2 x i8> @returns_contain_zero_range_helper_vec() 1415b3ca9c30SNoah Goldstein; CHECK-NEXT: [[OR:%.*]] = or <2 x i8> [[Y:%.*]], [[X]] 1416e66cfebbSAndreas Jonson; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i8> [[OR]], zeroinitializer 1417e66cfebbSAndreas Jonson; CHECK-NEXT: ret <2 x i1> [[CMP]] 1418e66cfebbSAndreas Jonson; 1419e66cfebbSAndreas Jonson %x = call <2 x i8> @returns_contain_zero_range_helper_vec() 1420e66cfebbSAndreas Jonson %or = or <2 x i8> %y, %x 1421e66cfebbSAndreas Jonson %cmp = icmp ne <2 x i8> %or, zeroinitializer 1422e66cfebbSAndreas Jonson ret <2 x i1> %cmp 1423e66cfebbSAndreas Jonson} 1424e66cfebbSAndreas Jonson 1425e66cfebbSAndreas Jonsondeclare <2 x i8> @returns_i8_helper_vec() 1426e66cfebbSAndreas Jonson 1427e66cfebbSAndreas Jonsondefine <2 x i1> @range_call_vec(<2 x i8> %y) { 1428e66cfebbSAndreas Jonson; CHECK-LABEL: @range_call_vec( 1429b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call range(i8 1, 0) <2 x i8> @returns_i8_helper_vec() 1430*38fffa63SPaul Walker; CHECK-NEXT: ret <2 x i1> splat (i1 true) 1431e66cfebbSAndreas Jonson; 1432e66cfebbSAndreas Jonson %x = call range(i8 1, 0) <2 x i8> @returns_i8_helper_vec() 1433e66cfebbSAndreas Jonson %or = or <2 x i8> %y, %x 1434e66cfebbSAndreas Jonson %cmp = icmp ne <2 x i8> %or, zeroinitializer 1435e66cfebbSAndreas Jonson ret <2 x i1> %cmp 1436e66cfebbSAndreas Jonson} 1437e66cfebbSAndreas Jonson 1438e66cfebbSAndreas Jonsondefine <2 x i1> @neg_range_call_vec(<2 x i8> %y) { 1439e66cfebbSAndreas Jonson; CHECK-LABEL: @neg_range_call_vec( 1440b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = call range(i8 -1, 1) <2 x i8> @returns_i8_helper_vec() 1441b3ca9c30SNoah Goldstein; CHECK-NEXT: [[OR:%.*]] = or <2 x i8> [[Y:%.*]], [[X]] 1442e66cfebbSAndreas Jonson; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i8> [[OR]], zeroinitializer 1443e66cfebbSAndreas Jonson; CHECK-NEXT: ret <2 x i1> [[CMP]] 1444e66cfebbSAndreas Jonson; 1445e66cfebbSAndreas Jonson %x = call range(i8 -1, 1) <2 x i8> @returns_i8_helper_vec() 1446e66cfebbSAndreas Jonson %or = or <2 x i8> %y, %x 1447e66cfebbSAndreas Jonson %cmp = icmp ne <2 x i8> %or, zeroinitializer 1448e66cfebbSAndreas Jonson ret <2 x i1> %cmp 1449e66cfebbSAndreas Jonson} 1450e66cfebbSAndreas Jonson 1451b3ca9c30SNoah Goldsteindefine i1 @trunc_nsw_non_zero(i8 %x) { 1452b3ca9c30SNoah Goldstein; CHECK-LABEL: @trunc_nsw_non_zero( 1453b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X_NE_Z:%.*]] = icmp ne i8 [[X:%.*]], 0 1454b3ca9c30SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NE_Z]]) 1455b933c844SNoah Goldstein; CHECK-NEXT: ret i1 true 1456b3ca9c30SNoah Goldstein; 1457b3ca9c30SNoah Goldstein %x_ne_z = icmp ne i8 %x, 0 1458b3ca9c30SNoah Goldstein call void @llvm.assume(i1 %x_ne_z) 1459b3ca9c30SNoah Goldstein %v = trunc nsw i8 %x to i4 1460b3ca9c30SNoah Goldstein %r = icmp ne i4 %v, 0 1461b3ca9c30SNoah Goldstein ret i1 %r 1462b3ca9c30SNoah Goldstein} 1463b3ca9c30SNoah Goldstein 1464b3ca9c30SNoah Goldsteindefine i1 @trunc_nuw_non_zero(i8 %xx) { 1465b3ca9c30SNoah Goldstein; CHECK-LABEL: @trunc_nuw_non_zero( 1466b933c844SNoah Goldstein; CHECK-NEXT: ret i1 false 1467b3ca9c30SNoah Goldstein; 1468b3ca9c30SNoah Goldstein %x = add nuw i8 %xx, 1 1469b3ca9c30SNoah Goldstein %v = trunc nuw i8 %x to i4 1470b3ca9c30SNoah Goldstein %r = icmp eq i4 %v, 0 1471b3ca9c30SNoah Goldstein ret i1 %r 1472b3ca9c30SNoah Goldstein} 1473b3ca9c30SNoah Goldstein 1474b3ca9c30SNoah Goldsteindefine i1 @trunc_non_zero_fail(i8 %x) { 1475b3ca9c30SNoah Goldstein; CHECK-LABEL: @trunc_non_zero_fail( 1476b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X_NE_Z:%.*]] = icmp ne i8 [[X:%.*]], 0 1477b3ca9c30SNoah Goldstein; CHECK-NEXT: call void @llvm.assume(i1 [[X_NE_Z]]) 1478b3ca9c30SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = trunc i8 [[X]] to i1 1479b3ca9c30SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 1480b3ca9c30SNoah Goldstein; 1481b3ca9c30SNoah Goldstein %x_ne_z = icmp ne i8 %x, 0 1482b3ca9c30SNoah Goldstein call void @llvm.assume(i1 %x_ne_z) 1483b3ca9c30SNoah Goldstein %r = trunc i8 %x to i1 1484b3ca9c30SNoah Goldstein ret i1 %r 1485b3ca9c30SNoah Goldstein} 1486b3ca9c30SNoah Goldstein 1487b3ca9c30SNoah Goldsteindefine i1 @trunc_nsw_nuw_non_zero_fail(i8 %xx) { 1488b3ca9c30SNoah Goldstein; CHECK-LABEL: @trunc_nsw_nuw_non_zero_fail( 1489b3ca9c30SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = add nsw i8 [[XX:%.*]], 1 1490b3ca9c30SNoah Goldstein; CHECK-NEXT: [[V:%.*]] = trunc nuw nsw i8 [[X]] to i4 1491b3ca9c30SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i4 [[V]], 0 1492b3ca9c30SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 1493b3ca9c30SNoah Goldstein; 1494b3ca9c30SNoah Goldstein %x = add nsw i8 %xx, 1 1495b3ca9c30SNoah Goldstein %v = trunc nsw nuw i8 %x to i4 1496b3ca9c30SNoah Goldstein %r = icmp eq i4 %v, 0 1497b3ca9c30SNoah Goldstein ret i1 %r 1498b3ca9c30SNoah Goldstein} 1499e66cfebbSAndreas Jonson 150041b876dbSNoah Goldsteindefine <4 x i1> @vec_reverse_non_zero(<4 x i8> %xx) { 150141b876dbSNoah Goldstein; CHECK-LABEL: @vec_reverse_non_zero( 1502769952d7SNoah Goldstein; CHECK-NEXT: ret <4 x i1> zeroinitializer 150341b876dbSNoah Goldstein; 150441b876dbSNoah Goldstein %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1> 150541b876dbSNoah Goldstein %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x) 150641b876dbSNoah Goldstein %r = icmp eq <4 x i8> %rev, zeroinitializer 150741b876dbSNoah Goldstein ret <4 x i1> %r 150841b876dbSNoah Goldstein} 150941b876dbSNoah Goldstein 151041b876dbSNoah Goldsteindefine <4 x i1> @vec_reverse_non_zero_fail(<4 x i8> %xx) { 151141b876dbSNoah Goldstein; CHECK-LABEL: @vec_reverse_non_zero_fail( 151241b876dbSNoah Goldstein; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 0, i8 1, i8 1> 151341b876dbSNoah Goldstein; CHECK-NEXT: [[REV:%.*]] = call <4 x i8> @llvm.vector.reverse.v4i8(<4 x i8> [[X]]) 151441b876dbSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq <4 x i8> [[REV]], zeroinitializer 151541b876dbSNoah Goldstein; CHECK-NEXT: ret <4 x i1> [[R]] 151641b876dbSNoah Goldstein; 151741b876dbSNoah Goldstein %x = add nuw <4 x i8> %xx, <i8 1, i8 0, i8 1, i8 1> 151841b876dbSNoah Goldstein %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x) 151941b876dbSNoah Goldstein %r = icmp eq <4 x i8> %rev, zeroinitializer 152041b876dbSNoah Goldstein ret <4 x i1> %r 152141b876dbSNoah Goldstein} 152241b876dbSNoah Goldstein 15231dfbd072SNoah Goldsteindefine i1 @vec_reverse_non_zero_demanded(<4 x i8> %xx) { 15241dfbd072SNoah Goldstein; CHECK-LABEL: @vec_reverse_non_zero_demanded( 152572ff0499SNoah Goldstein; CHECK-NEXT: ret i1 false 15261dfbd072SNoah Goldstein; 15271dfbd072SNoah Goldstein %x = add nuw <4 x i8> %xx, <i8 1, i8 0, i8 0, i8 0> 15281dfbd072SNoah Goldstein %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x) 15291dfbd072SNoah Goldstein %ele = extractelement <4 x i8> %rev, i64 3 15301dfbd072SNoah Goldstein %r = icmp eq i8 %ele, 0 15311dfbd072SNoah Goldstein ret i1 %r 15321dfbd072SNoah Goldstein} 15331dfbd072SNoah Goldstein 15341dfbd072SNoah Goldsteindefine i1 @vec_reverse_non_zero_demanded_fail(<4 x i8> %xx) { 15351dfbd072SNoah Goldstein; CHECK-LABEL: @vec_reverse_non_zero_demanded_fail( 15361dfbd072SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 0, i8 0, i8 0> 15371dfbd072SNoah Goldstein; CHECK-NEXT: [[REV:%.*]] = call <4 x i8> @llvm.vector.reverse.v4i8(<4 x i8> [[X]]) 15381dfbd072SNoah Goldstein; CHECK-NEXT: [[ELE:%.*]] = extractelement <4 x i8> [[REV]], i64 2 15391dfbd072SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[ELE]], 0 15401dfbd072SNoah Goldstein; CHECK-NEXT: ret i1 [[R]] 15411dfbd072SNoah Goldstein; 15421dfbd072SNoah Goldstein %x = add nuw <4 x i8> %xx, <i8 1, i8 0, i8 0, i8 0> 15431dfbd072SNoah Goldstein %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x) 15441dfbd072SNoah Goldstein %ele = extractelement <4 x i8> %rev, i64 2 15451dfbd072SNoah Goldstein %r = icmp eq i8 %ele, 0 15461dfbd072SNoah Goldstein ret i1 %r 15471dfbd072SNoah Goldstein} 15481dfbd072SNoah Goldstein 1549d8e1b451SCraig Topperdeclare i32 @llvm.experimental.get.vector.length.i32(i32, i32, i1) 1550