1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -correlated-propagation < %s | FileCheck %s
4 declare i32 @llvm.umin.i32(i32, i32)
5 declare i32 @llvm.umax.i32(i32, i32)
6 declare i32 @llvm.smin.i32(i32, i32)
7 declare i32 @llvm.smax.i32(i32, i32)
8 declare i32 @llvm.abs.i32(i32, i1)
11 define void @test_umin(i32 %x) {
12 ; CHECK-LABEL: @test_umin(
13 ; CHECK-NEXT: [[M:%.*]] = call i32 @llvm.umin.i32(i32 [[X:%.*]], i32 10)
14 ; CHECK-NEXT: call void @use(i1 true)
15 ; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[M]], 10
16 ; CHECK-NEXT: call void @use(i1 [[C2]])
17 ; CHECK-NEXT: ret void
19 %m = call i32 @llvm.umin.i32(i32 %x, i32 10)
20 %c1 = icmp ule i32 %m, 10
21 call void @use(i1 %c1)
22 %c2 = icmp ult i32 %m, 10
23 call void @use(i1 %c2)
27 define void @test_umax(i32 %x) {
28 ; CHECK-LABEL: @test_umax(
29 ; CHECK-NEXT: [[M:%.*]] = call i32 @llvm.umax.i32(i32 [[X:%.*]], i32 10)
30 ; CHECK-NEXT: call void @use(i1 true)
31 ; CHECK-NEXT: [[C2:%.*]] = icmp ugt i32 [[M]], 10
32 ; CHECK-NEXT: call void @use(i1 [[C2]])
33 ; CHECK-NEXT: ret void
35 %m = call i32 @llvm.umax.i32(i32 %x, i32 10)
36 %c1 = icmp uge i32 %m, 10
37 call void @use(i1 %c1)
38 %c2 = icmp ugt i32 %m, 10
39 call void @use(i1 %c2)
43 define void @test_smin(i32 %x) {
44 ; CHECK-LABEL: @test_smin(
45 ; CHECK-NEXT: [[M:%.*]] = call i32 @llvm.smin.i32(i32 [[X:%.*]], i32 10)
46 ; CHECK-NEXT: call void @use(i1 true)
47 ; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[M]], 10
48 ; CHECK-NEXT: call void @use(i1 [[C2]])
49 ; CHECK-NEXT: ret void
51 %m = call i32 @llvm.smin.i32(i32 %x, i32 10)
52 %c1 = icmp sle i32 %m, 10
53 call void @use(i1 %c1)
54 %c2 = icmp slt i32 %m, 10
55 call void @use(i1 %c2)
59 define void @test_smax(i32 %x) {
60 ; CHECK-LABEL: @test_smax(
61 ; CHECK-NEXT: [[M:%.*]] = call i32 @llvm.smax.i32(i32 [[X:%.*]], i32 10)
62 ; CHECK-NEXT: call void @use(i1 true)
63 ; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[M]], 10
64 ; CHECK-NEXT: call void @use(i1 [[C2]])
65 ; CHECK-NEXT: ret void
67 %m = call i32 @llvm.smax.i32(i32 %x, i32 10)
68 %c1 = icmp sge i32 %m, 10
69 call void @use(i1 %c1)
70 %c2 = icmp sgt i32 %m, 10
71 call void @use(i1 %c2)
75 define void @test_abs1(i32* %p) {
76 ; CHECK-LABEL: @test_abs1(
77 ; CHECK-NEXT: [[X:%.*]] = load i32, i32* [[P:%.*]], align 4, !range [[RNG0:![0-9]+]]
78 ; CHECK-NEXT: [[A:%.*]] = call i32 @llvm.abs.i32(i32 [[X]], i1 true)
79 ; CHECK-NEXT: call void @use(i1 true)
80 ; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[A]], 15
81 ; CHECK-NEXT: call void @use(i1 [[C2]])
82 ; CHECK-NEXT: ret void
84 %x = load i32, i32* %p, !range !{i32 -15, i32 10}
85 %a = call i32 @llvm.abs.i32(i32 %x, i1 false)
86 %c1 = icmp ule i32 %a, 15
87 call void @use(i1 %c1)
88 %c2 = icmp ult i32 %a, 15
89 call void @use(i1 %c2)
93 define void @test_abs2(i32 %x) {
94 ; CHECK-LABEL: @test_abs2(
95 ; CHECK-NEXT: [[A:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false)
96 ; CHECK-NEXT: call void @use(i1 true)
97 ; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[A]], -2147483648
98 ; CHECK-NEXT: call void @use(i1 [[C2]])
99 ; CHECK-NEXT: ret void
101 %a = call i32 @llvm.abs.i32(i32 %x, i1 false)
102 %c1 = icmp ule i32 %a, 2147483648
103 call void @use(i1 %c1)
104 %c2 = icmp ult i32 %a, 2147483648
105 call void @use(i1 %c2)
109 define void @test_abs3(i32 %x) {
110 ; CHECK-LABEL: @test_abs3(
111 ; CHECK-NEXT: [[A:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
112 ; CHECK-NEXT: call void @use(i1 true)
113 ; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[A]], 0
114 ; CHECK-NEXT: call void @use(i1 [[C2]])
115 ; CHECK-NEXT: ret void
117 %a = call i32 @llvm.abs.i32(i32 %x, i1 true)
118 %c1 = icmp sge i32 %a, 0
119 call void @use(i1 %c1)
120 %c2 = icmp sgt i32 %a, 0
121 call void @use(i1 %c2)