1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -ipsccp -S %s | FileCheck %s 3 4declare i8 @llvm.abs.i8(i8, i1) 5declare <2 x i8> @llvm.abs.v2i8(<2 x i8>, i1) 6declare i8 @llvm.umax.i8(i8, i8) 7 8declare void @use(i1) 9declare void @use_vec(<2 x i1>) 10 11define void @abs1(i8* %p) { 12; CHECK-LABEL: @abs1( 13; CHECK-NEXT: [[X:%.*]] = load i8, i8* [[P:%.*]], align 1, [[RNG0:!range !.*]] 14; CHECK-NEXT: [[ABS:%.*]] = call i8 @llvm.abs.i8(i8 [[X]], i1 false) 15; CHECK-NEXT: call void @use(i1 true) 16; CHECK-NEXT: call void @use(i1 true) 17; CHECK-NEXT: [[CMP3:%.*]] = icmp sge i8 [[ABS]], 1 18; CHECK-NEXT: call void @use(i1 [[CMP3]]) 19; CHECK-NEXT: [[CMP4:%.*]] = icmp slt i8 [[ABS]], 9 20; CHECK-NEXT: call void @use(i1 [[CMP4]]) 21; CHECK-NEXT: ret void 22; 23 %x = load i8, i8* %p, !range !{i8 -9, i8 10} 24 %abs = call i8 @llvm.abs.i8(i8 %x, i1 false) 25 %cmp1 = icmp sge i8 %abs, 0 26 call void @use(i1 %cmp1) 27 %cmp2 = icmp slt i8 %abs, 10 28 call void @use(i1 %cmp2) 29 %cmp3 = icmp sge i8 %abs, 1 30 call void @use(i1 %cmp3) 31 %cmp4 = icmp slt i8 %abs, 9 32 call void @use(i1 %cmp4) 33 ret void 34} 35 36; Even if we don't know anything about the input range of the operand, 37; we still know something about the result range of abs(). 38define void @abs2(i8 %x) { 39; CHECK-LABEL: @abs2( 40; CHECK-NEXT: [[ABS:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 true) 41; CHECK-NEXT: call void @use(i1 true) 42; CHECK-NEXT: ret void 43; 44 %abs = call i8 @llvm.abs.i8(i8 %x, i1 true) 45 %cmp = icmp sge i8 %abs, 0 46 call void @use(i1 %cmp) 47 ret void 48} 49 50define void @abs2_vec(<2 x i8> %x) { 51; CHECK-LABEL: @abs2_vec( 52; CHECK-NEXT: [[ABS:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[X:%.*]], i1 true) 53; CHECK-NEXT: [[CMP:%.*]] = icmp sge <2 x i8> [[ABS]], zeroinitializer 54; CHECK-NEXT: call void @use_vec(<2 x i1> [[CMP]]) 55; CHECK-NEXT: ret void 56; 57 %abs = call <2 x i8> @llvm.abs.v2i8(<2 x i8> %x, i1 true) 58 %cmp = icmp sge <2 x i8> %abs, zeroinitializer 59 call void @use_vec(<2 x i1> %cmp) 60 ret void 61} 62 63define void @umax1(i8* %p1, i8* %p2) { 64; CHECK-LABEL: @umax1( 65; CHECK-NEXT: [[X1:%.*]] = load i8, i8* [[P1:%.*]], align 1, [[RNG1:!range !.*]] 66; CHECK-NEXT: [[X2:%.*]] = load i8, i8* [[P2:%.*]], align 1, [[RNG2:!range !.*]] 67; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X1]], i8 [[X2]]) 68; CHECK-NEXT: call void @use(i1 true) 69; CHECK-NEXT: call void @use(i1 true) 70; CHECK-NEXT: [[CMP3:%.*]] = icmp uge i8 [[M]], 6 71; CHECK-NEXT: call void @use(i1 [[CMP3]]) 72; CHECK-NEXT: [[CMP4:%.*]] = icmp ult i8 [[M]], 14 73; CHECK-NEXT: call void @use(i1 [[CMP4]]) 74; CHECK-NEXT: ret void 75; 76 %x1 = load i8, i8* %p1, !range !{i8 0, i8 10} 77 %x2 = load i8, i8* %p2, !range !{i8 5, i8 15} 78 %m = call i8 @llvm.umax.i8(i8 %x1, i8 %x2) 79 %cmp1 = icmp uge i8 %m, 5 80 call void @use(i1 %cmp1) 81 %cmp2 = icmp ult i8 %m, 15 82 call void @use(i1 %cmp2) 83 %cmp3 = icmp uge i8 %m, 6 84 call void @use(i1 %cmp3) 85 %cmp4 = icmp ult i8 %m, 14 86 call void @use(i1 %cmp4) 87 ret void 88} 89 90define void @umax2(i8 %x) { 91; CHECK-LABEL: @umax2( 92; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 10) 93; CHECK-NEXT: call void @use(i1 true) 94; CHECK-NEXT: ret void 95; 96 %m = call i8 @llvm.umax.i8(i8 %x, i8 10) 97 %cmp = icmp uge i8 %m, 10 98 call void @use(i1 %cmp) 99 ret void 100} 101