1 ; RUN: opt -basicaa -loop-distribute -enable-loop-distribute=0 -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=EXPLICIT --check-prefix=DEFAULT_OFF 2 ; RUN: opt -basicaa -loop-distribute -enable-loop-distribute=1 -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=EXPLICIT --check-prefix=DEFAULT_ON 3 4 ; Same loop as in basic.ll. Check that distribution is enabled/disabled 5 ; properly according to -enable-loop-distribute=0/1 and the 6 ; llvm.loop.distribute.enable metadata. 7 8 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 9 target triple = "x86_64-apple-macosx10.10.0" 10 11 ; CHECK-LABEL: @explicit_on( 12 define void @explicit_on(i32* noalias %a, 13 i32* noalias %b, 14 i32* noalias %c, 15 i32* noalias %d, 16 i32* noalias %e) { 17 entry: 18 br label %for.body 19 20 ; EXPLICIT: for.body.ldist1: 21 22 for.body: ; preds = %for.body, %entry 23 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ] 24 25 %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind 26 %loadA = load i32, i32* %arrayidxA, align 4 27 28 %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %ind 29 %loadB = load i32, i32* %arrayidxB, align 4 30 31 %mulA = mul i32 %loadB, %loadA 32 33 %add = add nuw nsw i64 %ind, 1 34 %arrayidxA_plus_4 = getelementptr inbounds i32, i32* %a, i64 %add 35 store i32 %mulA, i32* %arrayidxA_plus_4, align 4 36 37 %arrayidxD = getelementptr inbounds i32, i32* %d, i64 %ind 38 %loadD = load i32, i32* %arrayidxD, align 4 39 40 %arrayidxE = getelementptr inbounds i32, i32* %e, i64 %ind 41 %loadE = load i32, i32* %arrayidxE, align 4 42 43 %mulC = mul i32 %loadD, %loadE 44 45 %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %ind 46 store i32 %mulC, i32* %arrayidxC, align 4 47 48 %exitcond = icmp eq i64 %add, 20 49 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0 50 51 for.end: ; preds = %for.body 52 ret void 53 } 54 55 ; CHECK-LABEL: @explicit_off( 56 define void @explicit_off(i32* noalias %a, 57 i32* noalias %b, 58 i32* noalias %c, 59 i32* noalias %d, 60 i32* noalias %e) { 61 entry: 62 br label %for.body 63 64 ; EXPLICIT-NOT: for.body.ldist1: 65 66 for.body: ; preds = %for.body, %entry 67 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ] 68 69 %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind 70 %loadA = load i32, i32* %arrayidxA, align 4 71 72 %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %ind 73 %loadB = load i32, i32* %arrayidxB, align 4 74 75 %mulA = mul i32 %loadB, %loadA 76 77 %add = add nuw nsw i64 %ind, 1 78 %arrayidxA_plus_4 = getelementptr inbounds i32, i32* %a, i64 %add 79 store i32 %mulA, i32* %arrayidxA_plus_4, align 4 80 81 %arrayidxD = getelementptr inbounds i32, i32* %d, i64 %ind 82 %loadD = load i32, i32* %arrayidxD, align 4 83 84 %arrayidxE = getelementptr inbounds i32, i32* %e, i64 %ind 85 %loadE = load i32, i32* %arrayidxE, align 4 86 87 %mulC = mul i32 %loadD, %loadE 88 89 %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %ind 90 store i32 %mulC, i32* %arrayidxC, align 4 91 92 %exitcond = icmp eq i64 %add, 20 93 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !2 94 95 for.end: ; preds = %for.body 96 ret void 97 } 98 99 ; CHECK-LABEL: @default_distribute( 100 define void @default_distribute(i32* noalias %a, 101 i32* noalias %b, 102 i32* noalias %c, 103 i32* noalias %d, 104 i32* noalias %e) { 105 entry: 106 br label %for.body 107 108 ; Verify the two distributed loops. 109 110 ; DEFAULT_ON: for.body.ldist1: 111 ; DEFAULT_OFF-NOT: for.body.ldist1: 112 113 for.body: ; preds = %for.body, %entry 114 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ] 115 116 %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind 117 %loadA = load i32, i32* %arrayidxA, align 4 118 119 %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %ind 120 %loadB = load i32, i32* %arrayidxB, align 4 121 122 %mulA = mul i32 %loadB, %loadA 123 124 %add = add nuw nsw i64 %ind, 1 125 %arrayidxA_plus_4 = getelementptr inbounds i32, i32* %a, i64 %add 126 store i32 %mulA, i32* %arrayidxA_plus_4, align 4 127 128 %arrayidxD = getelementptr inbounds i32, i32* %d, i64 %ind 129 %loadD = load i32, i32* %arrayidxD, align 4 130 131 %arrayidxE = getelementptr inbounds i32, i32* %e, i64 %ind 132 %loadE = load i32, i32* %arrayidxE, align 4 133 134 %mulC = mul i32 %loadD, %loadE 135 136 %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %ind 137 store i32 %mulC, i32* %arrayidxC, align 4 138 139 %exitcond = icmp eq i64 %add, 20 140 br i1 %exitcond, label %for.end, label %for.body 141 142 for.end: ; preds = %for.body 143 ret void 144 } 145 146 !0 = distinct !{!0, !1} 147 !1 = !{!"llvm.loop.distribute.enable", i1 true} 148 !2 = distinct !{!2, !3} 149 !3 = !{!"llvm.loop.distribute.enable", i1 false} 150