1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes='loop(loop-flatten),verify' -verify-loop-info -verify-dom-info -verify-scev | FileCheck %s
4 ; Check that the mul does not have extra uses.
6 define void @test0(ptr %arg, ptr %arg1) {
9 ; CHECK-NEXT: br label [[DOTPREHEADER:%.*]]
11 ; CHECK-NEXT: [[I:%.*]] = phi i64 [ 0, [[BB:%.*]] ], [ [[I5:%.*]], [[BB4:%.*]] ]
12 ; CHECK-NEXT: [[I2:%.*]] = mul i64 [[I]], 3
13 ; CHECK-NEXT: [[I3:%.*]] = getelementptr i16, ptr [[ARG1:%.*]], i64 [[I2]]
14 ; CHECK-NEXT: br label [[BB7:%.*]]
16 ; CHECK-NEXT: [[I5]] = add i64 [[I]], 1
17 ; CHECK-NEXT: [[I6:%.*]] = icmp slt i64 [[I5]], 2
18 ; CHECK-NEXT: br i1 [[I6]], label [[DOTPREHEADER]], label [[BB14:%.*]]
20 ; CHECK-NEXT: [[I8:%.*]] = phi i64 [ 0, [[DOTPREHEADER]] ], [ [[I12:%.*]], [[BB7]] ]
21 ; CHECK-NEXT: [[I9:%.*]] = load i16, ptr [[I3]], align 2
22 ; CHECK-NEXT: [[I10:%.*]] = add i64 [[I8]], [[I2]]
23 ; CHECK-NEXT: [[I11:%.*]] = getelementptr i16, ptr [[ARG:%.*]], i64 [[I10]]
24 ; CHECK-NEXT: store i16 [[I9]], ptr [[I11]], align 2
25 ; CHECK-NEXT: [[I12]] = add nuw nsw i64 [[I8]], 1
26 ; CHECK-NEXT: [[I13:%.*]] = icmp ult i64 [[I12]], 3
27 ; CHECK-NEXT: br i1 [[I13]], label [[BB7]], label [[BB4]]
29 ; CHECK-NEXT: ret void
34 .preheader: ; preds = %bb4, %bb
35 %i = phi i64 [ 0, %bb ], [ %i5, %bb4 ]
37 %i3 = getelementptr i16, ptr %arg1, i64 %i2
42 %i6 = icmp slt i64 %i5, 2
43 br i1 %i6, label %.preheader, label %bb14
45 bb7: ; preds = %bb7, %.preheader
46 %i8 = phi i64 [ 0, %.preheader ], [ %i12, %bb7 ]
47 %i9 = load i16, ptr %i3, align 2
48 %i10 = add i64 %i8, %i2
49 %i11 = getelementptr i16, ptr %arg, i64 %i10
50 store i16 %i9, ptr %i11, align 2
51 %i12 = add nuw nsw i64 %i8, 1
52 %i13 = icmp ult i64 %i12, 3
53 br i1 %i13, label %bb7, label %bb4