1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -indvars -S | FileCheck %s
4 define i32 @logical_and_2ops(i32 %n, i32 %m) {
5 ; CHECK-LABEL: @logical_and_2ops(
7 ; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[M:%.*]], i32 [[N:%.*]])
8 ; CHECK-NEXT: br label [[LOOP:%.*]]
10 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
12 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[N]], 0
13 ; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[TMP0]], i32 0, i32 [[UMIN]]
14 ; CHECK-NEXT: ret i32 [[TMP1]]
19 %i = phi i32 [0, %entry], [%i.next, %loop]
20 %i.next = add i32 %i, 1
21 %cond_p0 = icmp ult i32 %i, %n
22 %cond_p1 = icmp ult i32 %i, %m
23 %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
24 br i1 %cond, label %loop, label %exit
29 define i32 @logical_or_2ops(i32 %n, i32 %m) {
30 ; CHECK-LABEL: @logical_or_2ops(
32 ; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[M:%.*]], i32 [[N:%.*]])
33 ; CHECK-NEXT: br label [[LOOP:%.*]]
35 ; CHECK-NEXT: br i1 true, label [[EXIT:%.*]], label [[LOOP]]
37 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[N]], 0
38 ; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[TMP0]], i32 0, i32 [[UMIN]]
39 ; CHECK-NEXT: ret i32 [[TMP1]]
44 %i = phi i32 [0, %entry], [%i.next, %loop]
45 %i.next = add i32 %i, 1
46 %cond_p0 = icmp uge i32 %i, %n
47 %cond_p1 = icmp uge i32 %i, %m
48 %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
49 br i1 %cond, label %exit, label %loop
54 define i32 @logical_and_3ops(i32 %n, i32 %m, i32 %k) {
55 ; CHECK-LABEL: @logical_and_3ops(
57 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[M:%.*]], 0
58 ; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[K:%.*]], i32 [[M]])
59 ; CHECK-NEXT: [[UMIN1:%.*]] = call i32 @llvm.umin.i32(i32 [[UMIN]], i32 [[N:%.*]])
60 ; CHECK-NEXT: br label [[LOOP:%.*]]
62 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
64 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[N]], 0
65 ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i1 true, i1 [[TMP0]]
66 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i32 0, i32 [[UMIN1]]
67 ; CHECK-NEXT: ret i32 [[TMP3]]
72 %i = phi i32 [0, %entry], [%i.next, %loop]
73 %i.next = add i32 %i, 1
74 %cond_p0 = icmp ult i32 %i, %n
75 %cond_p1 = icmp ult i32 %i, %m
76 %cond_p2 = icmp ult i32 %i, %k
77 %cond_p3 = select i1 %cond_p0, i1 %cond_p1, i1 false
78 %cond = select i1 %cond_p3, i1 %cond_p2, i1 false
79 br i1 %cond, label %loop, label %exit
84 define i32 @logical_or_3ops(i32 %n, i32 %m, i32 %k) {
85 ; CHECK-LABEL: @logical_or_3ops(
87 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[M:%.*]], 0
88 ; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[K:%.*]], i32 [[M]])
89 ; CHECK-NEXT: [[UMIN1:%.*]] = call i32 @llvm.umin.i32(i32 [[UMIN]], i32 [[N:%.*]])
90 ; CHECK-NEXT: br label [[LOOP:%.*]]
92 ; CHECK-NEXT: br i1 true, label [[EXIT:%.*]], label [[LOOP]]
94 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[N]], 0
95 ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i1 true, i1 [[TMP0]]
96 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i32 0, i32 [[UMIN1]]
97 ; CHECK-NEXT: ret i32 [[TMP3]]
102 %i = phi i32 [0, %entry], [%i.next, %loop]
103 %i.next = add i32 %i, 1
104 %cond_p0 = icmp uge i32 %i, %n
105 %cond_p1 = icmp uge i32 %i, %m
106 %cond_p2 = icmp uge i32 %i, %k
107 %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
108 %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
109 br i1 %cond, label %exit, label %loop