1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -passes=indvars < %s | FileCheck %s
6 ; Make sure the division does not get expanded into the preheader.
8 define i32 @test(i32 %arg) {
9 ; CHECK-LABEL: define i32 @test
10 ; CHECK-SAME: (i32 [[ARG:%.*]]) {
12 ; CHECK-NEXT: br label [[LOOP:%.*]]
14 ; CHECK-NEXT: br i1 false, label [[IF:%.*]], label [[LOOP_LATCH:%.*]]
16 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 7, [[ARG]]
17 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 1, [[DIV]]
18 ; CHECK-NEXT: call void @use(i1 [[CMP2]])
19 ; CHECK-NEXT: br label [[LOOP_LATCH]]
21 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
23 ; CHECK-NEXT: ret i32 1
29 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
30 %iv.next = add i32 %iv, 1
31 %cmp = icmp eq i32 %iv, 1
32 br i1 %cmp, label %if, label %loop.latch
35 %div = udiv i32 7, %arg
36 %cmp2 = icmp ult i32 %iv.next, %div
37 call void @use(i1 %cmp2)
41 br i1 false, label %loop, label %exit
44 %inc.lcssa = phi i32 [ %iv.next, %loop.latch ]