1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=indvars -S < %s | FileCheck %s
6 define void @test(ptr %arg) {
9 ; CHECK-NEXT: [[O:%.*]] = getelementptr ptr, ptr [[ARG:%.*]], i64 16
10 ; CHECK-NEXT: call void @c(ptr [[O]])
11 ; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[ARG]], i64 16
12 ; CHECK-NEXT: br label [[LOOP:%.*]]
14 ; CHECK-NEXT: [[IDX:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[LOOP]] ]
15 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[IDX]], 1
16 ; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[INC]], 16
17 ; CHECK-NEXT: call void @c(ptr [[UGLYGEP]])
18 ; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[END:%.*]]
20 ; CHECK-NEXT: ret void
23 %o = getelementptr ptr, ptr %arg, i64 16
27 %idx = phi i32 [ 1, %entry ], [ %inc, %loop ]
28 %inc = add i32 %idx, 1
29 %c = icmp ne i32 %inc, 16
30 %p = getelementptr ptr, ptr %arg, i32 2
31 %p1 = getelementptr ptr, ptr %p, i32 %idx
32 %neg = sub i32 0, %idx
33 %p2 = getelementptr ptr, ptr %p1, i32 %neg
35 br i1 %c, label %loop, label %end