1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=indvars -S | FileCheck %s
4 define i32 @logical_and_2ops(i32 %n, i32 %m) {
5 ; CHECK-LABEL: @logical_and_2ops(
7 ; CHECK-NEXT: [[TMP0:%.*]] = freeze i32 [[M:%.*]]
8 ; CHECK-NEXT: br label [[LOOP:%.*]]
10 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
12 ; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[TMP0]], i32 [[N:%.*]])
13 ; CHECK-NEXT: ret i32 [[UMIN]]
18 %i = phi i32 [0, %entry], [%i.next, %loop]
19 %i.next = add i32 %i, 1
20 %cond_p0 = icmp ult i32 %i, %n
21 %cond_p1 = icmp ult i32 %i, %m
22 %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
23 br i1 %cond, label %loop, label %exit
28 define i32 @logical_or_2ops(i32 %n, i32 %m) {
29 ; CHECK-LABEL: @logical_or_2ops(
31 ; CHECK-NEXT: [[TMP0:%.*]] = freeze i32 [[M:%.*]]
32 ; CHECK-NEXT: br label [[LOOP:%.*]]
34 ; CHECK-NEXT: br i1 true, label [[EXIT:%.*]], label [[LOOP]]
36 ; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[TMP0]], i32 [[N:%.*]])
37 ; CHECK-NEXT: ret i32 [[UMIN]]
42 %i = phi i32 [0, %entry], [%i.next, %loop]
43 %i.next = add i32 %i, 1
44 %cond_p0 = icmp uge i32 %i, %n
45 %cond_p1 = icmp uge i32 %i, %m
46 %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
47 br i1 %cond, label %exit, label %loop
52 define i32 @logical_and_3ops(i32 %n, i32 %m, i32 %k) {
53 ; CHECK-LABEL: @logical_and_3ops(
55 ; CHECK-NEXT: [[TMP0:%.*]] = freeze i32 [[K:%.*]]
56 ; CHECK-NEXT: [[TMP1:%.*]] = freeze i32 [[M:%.*]]
57 ; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[TMP0]], i32 [[TMP1]])
58 ; CHECK-NEXT: br label [[LOOP:%.*]]
60 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
62 ; CHECK-NEXT: [[UMIN1:%.*]] = call i32 @llvm.umin.i32(i32 [[UMIN]], i32 [[N:%.*]])
63 ; CHECK-NEXT: ret i32 [[UMIN1]]
68 %i = phi i32 [0, %entry], [%i.next, %loop]
69 %i.next = add i32 %i, 1
70 %cond_p0 = icmp ult i32 %i, %n
71 %cond_p1 = icmp ult i32 %i, %m
72 %cond_p2 = icmp ult i32 %i, %k
73 %cond_p3 = select i1 %cond_p0, i1 %cond_p1, i1 false
74 %cond = select i1 %cond_p3, i1 %cond_p2, i1 false
75 br i1 %cond, label %loop, label %exit
80 define i32 @logical_or_3ops(i32 %n, i32 %m, i32 %k) {
81 ; CHECK-LABEL: @logical_or_3ops(
83 ; CHECK-NEXT: [[TMP0:%.*]] = freeze i32 [[K:%.*]]
84 ; CHECK-NEXT: [[TMP1:%.*]] = freeze i32 [[M:%.*]]
85 ; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[TMP0]], i32 [[TMP1]])
86 ; CHECK-NEXT: br label [[LOOP:%.*]]
88 ; CHECK-NEXT: br i1 true, label [[EXIT:%.*]], label [[LOOP]]
90 ; CHECK-NEXT: [[UMIN1:%.*]] = call i32 @llvm.umin.i32(i32 [[UMIN]], i32 [[N:%.*]])
91 ; CHECK-NEXT: ret i32 [[UMIN1]]
96 %i = phi i32 [0, %entry], [%i.next, %loop]
97 %i.next = add i32 %i, 1
98 %cond_p0 = icmp uge i32 %i, %n
99 %cond_p1 = icmp uge i32 %i, %m
100 %cond_p2 = icmp uge i32 %i, %k
101 %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
102 %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
103 br i1 %cond, label %exit, label %loop