137 lines · plain
1; RUN: opt -passes=loop-distribute -enable-loop-distribute=0 -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=EXPLICIT --check-prefix=DEFAULT_OFF2; RUN: opt -passes=loop-distribute -enable-loop-distribute=1 -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=EXPLICIT --check-prefix=DEFAULT_ON3 4; Same loop as in basic.ll. Check that distribution is enabled/disabled5; properly according to -enable-loop-distribute=0/1 and the6; llvm.loop.distribute.enable metadata.7 8define void @explicit_on(ptr noalias %a, ptr noalias %b, ptr noalias %c, ptr noalias %d, ptr noalias %e) {9; CHECK-LABEL: @explicit_on(10entry:11 br label %for.body12 13; EXPLICIT: for.body.ldist1:14for.body: ; preds = %for.body, %entry15 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]16 17 %arrayidxA = getelementptr inbounds i32, ptr %a, i64 %ind18 %loadA = load i32, ptr %arrayidxA, align 419 20 %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %ind21 %loadB = load i32, ptr %arrayidxB, align 422 23 %mulA = mul i32 %loadB, %loadA24 25 %add = add nuw nsw i64 %ind, 126 %arrayidxA_plus_4 = getelementptr inbounds i32, ptr %a, i64 %add27 store i32 %mulA, ptr %arrayidxA_plus_4, align 428 29 %arrayidxD = getelementptr inbounds i32, ptr %d, i64 %ind30 %loadD = load i32, ptr %arrayidxD, align 431 32 %arrayidxE = getelementptr inbounds i32, ptr %e, i64 %ind33 %loadE = load i32, ptr %arrayidxE, align 434 35 %mulC = mul i32 %loadD, %loadE36 37 %arrayidxC = getelementptr inbounds i32, ptr %c, i64 %ind38 store i32 %mulC, ptr %arrayidxC, align 439 40 %exitcond = icmp eq i64 %add, 2041 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !042 43for.end: ; preds = %for.body44 ret void45}46 47; CHECK-LABEL: @explicit_off(48define void @explicit_off(ptr noalias %a,49 ptr noalias %b,50 ptr noalias %c,51 ptr noalias %d,52 ptr noalias %e) {53entry:54 br label %for.body55 56; EXPLICIT-NOT: for.body.ldist1:57for.body: ; preds = %for.body, %entry58 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]59 60 %arrayidxA = getelementptr inbounds i32, ptr %a, i64 %ind61 %loadA = load i32, ptr %arrayidxA, align 462 63 %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %ind64 %loadB = load i32, ptr %arrayidxB, align 465 66 %mulA = mul i32 %loadB, %loadA67 68 %add = add nuw nsw i64 %ind, 169 %arrayidxA_plus_4 = getelementptr inbounds i32, ptr %a, i64 %add70 store i32 %mulA, ptr %arrayidxA_plus_4, align 471 72 %arrayidxD = getelementptr inbounds i32, ptr %d, i64 %ind73 %loadD = load i32, ptr %arrayidxD, align 474 75 %arrayidxE = getelementptr inbounds i32, ptr %e, i64 %ind76 %loadE = load i32, ptr %arrayidxE, align 477 78 %mulC = mul i32 %loadD, %loadE79 80 %arrayidxC = getelementptr inbounds i32, ptr %c, i64 %ind81 store i32 %mulC, ptr %arrayidxC, align 482 83 %exitcond = icmp eq i64 %add, 2084 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !285 86for.end: ; preds = %for.body87 ret void88}89 90define void @default_distribute(ptr noalias %a, ptr noalias %b, ptr noalias %c, ptr noalias %d,91 ptr noalias %e) {92; CHECK-LABEL: @default_distribute(93entry:94 br label %for.body95 96; Verify the two distributed loops.97 98; DEFAULT_ON: for.body.ldist1:99; DEFAULT_OFF-NOT: for.body.ldist1:100for.body: ; preds = %for.body, %entry101 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]102 103 %arrayidxA = getelementptr inbounds i32, ptr %a, i64 %ind104 %loadA = load i32, ptr %arrayidxA, align 4105 106 %arrayidxB = getelementptr inbounds i32, ptr %b, i64 %ind107 %loadB = load i32, ptr %arrayidxB, align 4108 109 %mulA = mul i32 %loadB, %loadA110 111 %add = add nuw nsw i64 %ind, 1112 %arrayidxA_plus_4 = getelementptr inbounds i32, ptr %a, i64 %add113 store i32 %mulA, ptr %arrayidxA_plus_4, align 4114 115 %arrayidxD = getelementptr inbounds i32, ptr %d, i64 %ind116 %loadD = load i32, ptr %arrayidxD, align 4117 118 %arrayidxE = getelementptr inbounds i32, ptr %e, i64 %ind119 %loadE = load i32, ptr %arrayidxE, align 4120 121 %mulC = mul i32 %loadD, %loadE122 123 %arrayidxC = getelementptr inbounds i32, ptr %c, i64 %ind124 store i32 %mulC, ptr %arrayidxC, align 4125 126 %exitcond = icmp eq i64 %add, 20127 br i1 %exitcond, label %for.end, label %for.body128 129for.end: ; preds = %for.body130 ret void131}132 133!0 = distinct !{!0, !1}134!1 = !{!"llvm.loop.distribute.enable", i1 true}135!2 = distinct !{!2, !3}136!3 = !{!"llvm.loop.distribute.enable", i1 false}137