1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -loop-reduce < %s | FileCheck %s
4 target datalayout = "e-p:64:64:64-n32:64"
6 define void @test1(ptr %p.start, i64 %len) {
9 ; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[P_START:%.*]], i64 4
10 ; CHECK-NEXT: br label [[LOOP:%.*]]
12 ; CHECK-NEXT: [[LSR_IV1:%.*]] = phi ptr [ [[UGLYGEP2:%.*]], [[LOOP]] ], [ [[UGLYGEP]], [[ENTRY:%.*]] ]
13 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi i64 [ [[LSR_IV_NEXT:%.*]], [[LOOP]] ], [ [[LEN:%.*]], [[ENTRY]] ]
14 ; CHECK-NEXT: [[TMP0:%.*]] = load volatile i32, ptr [[LSR_IV1]], align 4
15 ; CHECK-NEXT: [[LSR_IV_NEXT]] = add i64 [[LSR_IV]], -1
16 ; CHECK-NEXT: [[UGLYGEP2]] = getelementptr i8, ptr [[LSR_IV1]], i64 4
17 ; CHECK-NEXT: [[C:%.*]] = icmp ne i64 [[LSR_IV_NEXT]], 0
18 ; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[EXIT:%.*]]
20 ; CHECK-NEXT: ret void
26 %i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
27 %p = phi ptr [ %p.start, %entry ], [ %p.next, %loop ]
28 %i.next = add nuw i64 %i, 1
29 %p.next = getelementptr i32, ptr %p, i64 1
30 load volatile i32, ptr %p.next
31 %c = icmp ne i64 %i.next, %len
32 br i1 %c, label %loop, label %exit