1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -dse -S %s | FileCheck %s 3 4declare i1 @cond() readnone 5 6define i32 @test() { 7; CHECK-LABEL: @test( 8; CHECK-NEXT: entry: 9; CHECK-NEXT: [[M0:%.*]] = alloca [4 x i32], align 16 10; CHECK-NEXT: br label [[LOOP_1:%.*]] 11; CHECK: loop.1: 12; CHECK-NEXT: br label [[LOOP_2:%.*]] 13; CHECK: loop.2: 14; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[LOOP_1]] ], [ [[IV_NEXT:%.*]], [[LOOP_2]] ] 15; CHECK-NEXT: [[PTR_1:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* [[M0]], i64 3, i64 [[IV]] 16; CHECK-NEXT: [[PTR_2:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* [[M0]], i64 0, i64 [[IV]] 17; CHECK-NEXT: store i32 20, i32* [[PTR_2]], align 4 18; CHECK-NEXT: store i32 30, i32* [[PTR_1]], align 4 19; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1 20; CHECK-NEXT: [[C_3:%.*]] = call i1 @cond() 21; CHECK-NEXT: br i1 [[C_3]], label [[LOOP_1_LATCH:%.*]], label [[LOOP_2]] 22; CHECK: loop.1.latch: 23; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond() 24; CHECK-NEXT: br i1 [[C_2]], label [[EXIT:%.*]], label [[LOOP_1]] 25; CHECK: exit: 26; CHECK-NEXT: [[PTR_3:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* [[M0]], i64 0, i64 1 27; CHECK-NEXT: [[LV:%.*]] = load i32, i32* [[PTR_3]], align 16 28; CHECK-NEXT: ret i32 [[LV]] 29; 30entry: 31 %M0 = alloca [4 x i32], align 16 32 br label %loop.1 33 34loop.1: 35 br label %loop.2 36 37loop.2: 38 %iv = phi i64 [ 0, %loop.1 ], [ %iv.next, %loop.2 ] 39 %ptr.1 = getelementptr inbounds [4 x i32], [4 x i32]* %M0, i64 3, i64 %iv 40 store i32 10, i32* %ptr.1, align 4 41 %ptr.2 = getelementptr inbounds [4 x i32], [4 x i32]* %M0, i64 0, i64 %iv 42 store i32 20, i32* %ptr.2, align 4 43 store i32 30, i32* %ptr.1, align 4 44 %iv.next = add nuw nsw i64 %iv, 1 45 %c.3 = call i1 @cond() 46 br i1 %c.3, label %loop.1.latch, label %loop.2 47 48loop.1.latch: 49 %c.2 = call i1 @cond() 50 br i1 %c.2, label %exit, label %loop.1 51 52exit: 53 %ptr.3 = getelementptr inbounds [4 x i32], [4 x i32]* %M0, i64 0, i64 1 54 %lv = load i32, i32* %ptr.3, align 16 55 ret i32 %lv 56 57 58} 59