; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 ; RUN: opt -S -passes=loop-fusion < %s 2>&1 | FileCheck %s @A = common global [1024 x [1024 x i32]] zeroinitializer, align 16 @B = common global [1024 x [1024 x i32]] zeroinitializer, align 16 define void @dep_free() { ; CHECK-LABEL: define void @dep_free() { ; CHECK-NEXT: [[BB:.*]]: ; CHECK-NEXT: br label %[[BB9:.*]] ; CHECK: [[BB9]]: ; CHECK-NEXT: [[INDVARS_IV6:%.*]] = phi i64 [ [[INDVARS_IV_NEXT7:%.*]], %[[BB35:.*]] ], [ 0, %[[BB]] ] ; CHECK-NEXT: [[DOT0:%.*]] = phi i32 [ 0, %[[BB]] ], [ [[TMP36:%.*]], %[[BB35]] ] ; CHECK-NEXT: [[EXITCOND8:%.*]] = icmp ne i64 [[INDVARS_IV6]], 100 ; CHECK-NEXT: br i1 [[EXITCOND8]], label %[[BB11:.*]], label %[[BB10:.*]] ; CHECK: [[BB10]]: ; CHECK-NEXT: br label %[[BB37:.*]] ; CHECK: [[BB11]]: ; CHECK-NEXT: br label %[[BB12:.*]] ; CHECK: [[BB12]]: ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], %[[BB21:.*]] ], [ 0, %[[BB11]] ] ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV]], 100 ; CHECK-NEXT: br i1 [[EXITCOND]], label %[[BB14:.*]], label %[[BB23_PREHEADER:.*]] ; CHECK: [[BB23_PREHEADER]]: ; CHECK-NEXT: br label %[[BB23:.*]] ; CHECK: [[BB14]]: ; CHECK-NEXT: [[TMP:%.*]] = add nsw i32 [[DOT0]], -3 ; CHECK-NEXT: [[TMP15:%.*]] = add nuw nsw i64 [[INDVARS_IV6]], 3 ; CHECK-NEXT: [[TMP16:%.*]] = trunc i64 [[TMP15]] to i32 ; CHECK-NEXT: [[TMP17:%.*]] = mul nsw i32 [[TMP]], [[TMP16]] ; CHECK-NEXT: [[TMP18:%.*]] = trunc i64 [[INDVARS_IV6]] to i32 ; CHECK-NEXT: [[TMP19:%.*]] = srem i32 [[TMP17]], [[TMP18]] ; CHECK-NEXT: [[TMP20:%.*]] = getelementptr inbounds [1024 x [1024 x i32]], ptr @A, i64 0, i64 [[INDVARS_IV6]], i64 [[INDVARS_IV]] ; CHECK-NEXT: store i32 [[TMP19]], ptr [[TMP20]], align 4 ; CHECK-NEXT: br label %[[BB21]] ; CHECK: [[BB21]]: ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: br label %[[BB12]] ; CHECK: [[BB23]]: ; CHECK-NEXT: [[INDVARS_IV3:%.*]] = phi i64 [ [[INDVARS_IV_NEXT4:%.*]], %[[BB33:.*]] ], [ 0, %[[BB23_PREHEADER]] ] ; CHECK-NEXT: [[EXITCOND5:%.*]] = icmp ne i64 [[INDVARS_IV3]], 100 ; CHECK-NEXT: br i1 [[EXITCOND5]], label %[[BB25:.*]], label %[[BB35]] ; CHECK: [[BB25]]: ; CHECK-NEXT: [[TMP26:%.*]] = add nsw i32 [[DOT0]], -3 ; CHECK-NEXT: [[TMP27:%.*]] = add nuw nsw i64 [[INDVARS_IV6]], 3 ; CHECK-NEXT: [[TMP28:%.*]] = trunc i64 [[TMP27]] to i32 ; CHECK-NEXT: [[TMP29:%.*]] = mul nsw i32 [[TMP26]], [[TMP28]] ; CHECK-NEXT: [[TMP30:%.*]] = trunc i64 [[INDVARS_IV6]] to i32 ; CHECK-NEXT: [[TMP31:%.*]] = srem i32 [[TMP29]], [[TMP30]] ; CHECK-NEXT: [[TMP32:%.*]] = getelementptr inbounds [1024 x [1024 x i32]], ptr @B, i64 0, i64 [[INDVARS_IV6]], i64 [[INDVARS_IV3]] ; CHECK-NEXT: store i32 [[TMP31]], ptr [[TMP32]], align 4 ; CHECK-NEXT: br label %[[BB33]] ; CHECK: [[BB33]]: ; CHECK-NEXT: [[INDVARS_IV_NEXT4]] = add nuw nsw i64 [[INDVARS_IV3]], 1 ; CHECK-NEXT: br label %[[BB23]] ; CHECK: [[BB35]]: ; CHECK-NEXT: [[INDVARS_IV_NEXT7]] = add nuw nsw i64 [[INDVARS_IV6]], 1 ; CHECK-NEXT: [[TMP36]] = add nuw nsw i32 [[DOT0]], 1 ; CHECK-NEXT: br label %[[BB9]] ; CHECK: [[BB37]]: ; CHECK-NEXT: ret void ; bb: br label %bb9 bb9: ; preds = %bb35, %bb %indvars.iv6 = phi i64 [ %indvars.iv.next7, %bb35 ], [ 0, %bb ] %.0 = phi i32 [ 0, %bb ], [ %tmp36, %bb35 ] %exitcond8 = icmp ne i64 %indvars.iv6, 100 br i1 %exitcond8, label %bb11, label %bb10 bb10: ; preds = %bb9 br label %bb37 bb11: ; preds = %bb9 br label %bb12 bb12: ; preds = %bb21, %bb11 %indvars.iv = phi i64 [ %indvars.iv.next, %bb21 ], [ 0, %bb11 ] %exitcond = icmp ne i64 %indvars.iv, 100 br i1 %exitcond, label %bb14, label %bb23 bb14: ; preds = %bb12 %tmp = add nsw i32 %.0, -3 %tmp15 = add nuw nsw i64 %indvars.iv6, 3 %tmp16 = trunc i64 %tmp15 to i32 %tmp17 = mul nsw i32 %tmp, %tmp16 %tmp18 = trunc i64 %indvars.iv6 to i32 %tmp19 = srem i32 %tmp17, %tmp18 %tmp20 = getelementptr inbounds [1024 x [1024 x i32]], ptr @A, i64 0, i64 %indvars.iv6, i64 %indvars.iv store i32 %tmp19, ptr %tmp20, align 4 br label %bb21 bb21: ; preds = %bb14 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 br label %bb12 bb23: ; preds = %bb33, %bb12 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %bb33 ], [ 0, %bb12 ] %exitcond5 = icmp ne i64 %indvars.iv3, 100 br i1 %exitcond5, label %bb25, label %bb35 bb25: ; preds = %bb23 %tmp26 = add nsw i32 %.0, -3 %tmp27 = add nuw nsw i64 %indvars.iv6, 3 %tmp28 = trunc i64 %tmp27 to i32 %tmp29 = mul nsw i32 %tmp26, %tmp28 %tmp30 = trunc i64 %indvars.iv6 to i32 %tmp31 = srem i32 %tmp29, %tmp30 %tmp32 = getelementptr inbounds [1024 x [1024 x i32]], ptr @B, i64 0, i64 %indvars.iv6, i64 %indvars.iv3 store i32 %tmp31, ptr %tmp32, align 4 br label %bb33 bb33: ; preds = %bb25 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1 br label %bb23 bb35: ; preds = %bb23 %indvars.iv.next7 = add nuw nsw i64 %indvars.iv6, 1 %tmp36 = add nuw nsw i32 %.0, 1 br label %bb9 bb37: ; preds = %bb10 ret void }