1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=ipsccp -S %s | FileCheck %s
4 declare i8 @llvm.abs.i8(i8, i1)
5 declare <2 x i8> @llvm.abs.v2i8(<2 x i8>, i1)
6 declare i8 @llvm.umax.i8(i8, i8)
9 declare void @use_vec(<2 x i1>)
11 define void @abs1(ptr %p) {
13 ; CHECK-NEXT: [[X:%.*]] = load i8, ptr [[P:%.*]], align 1, !range [[RNG0:![0-9]+]]
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
23 %x = load i8, ptr %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)
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().
38 define void @abs2(i8 %x) {
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
44 %abs = call i8 @llvm.abs.i8(i8 %x, i1 true)
45 %cmp = icmp sge i8 %abs, 0
46 call void @use(i1 %cmp)
50 define 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
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)
63 define void @umax1(ptr %p1, ptr %p2) {
64 ; CHECK-LABEL: @umax1(
65 ; CHECK-NEXT: [[X1:%.*]] = load i8, ptr [[P1:%.*]], align 1, !range [[RNG1:![0-9]+]]
66 ; CHECK-NEXT: [[X2:%.*]] = load i8, ptr [[P2:%.*]], align 1, !range [[RNG2:![0-9]+]]
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
76 %x1 = load i8, ptr %p1, !range !{i8 0, i8 10}
77 %x2 = load i8, ptr %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)
90 define 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
96 %m = call i8 @llvm.umax.i8(i8 %x, i8 10)
97 %cmp = icmp uge i8 %m, 10
98 call void @use(i1 %cmp)
102 define i8 @umax_including_undef(i1 %c.1, i1 %c.2) {
103 ; CHECK-LABEL: @umax_including_undef(
104 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[TRUE:%.*]], label [[FALSE:%.*]]
106 ; CHECK-NEXT: br label [[EXIT:%.*]]
108 ; CHECK-NEXT: br label [[EXIT]]
110 ; CHECK-NEXT: ret i8 3
112 br i1 %c.1, label %true, label %false
121 %p = phi i8 [ 3, %true], [ undef, %false ]
122 %p_umax = call i8 @llvm.umax.i8(i8 %p, i8 1)
126 define <4 x i32> @pr63380(<4 x i32> %input) {
127 ; CHECK-LABEL: @pr63380(
128 ; CHECK-NEXT: [[CTLZ_1:%.*]] = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> [[INPUT:%.*]], i1 false)
129 ; CHECK-NEXT: [[CTLZ_2:%.*]] = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> [[CTLZ_1]], i1 true)
130 ; CHECK-NEXT: ret <4 x i32> splat (i32 27)
132 %ctlz.1 = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %input, i1 false)
133 %ctlz.2 = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %ctlz.1, i1 true)
134 %ctlz.3 = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %ctlz.2, i1 true)
135 ret <4 x i32> %ctlz.3
138 declare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>, i1 immarg)