brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.8 KiB · 8221e6a Raw
208 lines · plain
1; RUN: opt < %s -S -passes=loop-unroll -unroll-count=4 | FileCheck -check-prefix=CHECK_COUNT4 %s2; RUN: opt < %s -S -passes=loop-unroll | FileCheck -check-prefix=CHECK_NOCOUNT %s3; RUN: opt < %s -S -passes='require<profile-summary>,function(loop-unroll)' -pgso | FileCheck -check-prefix=PGSO %s4; RUN: opt < %s -S -passes='require<profile-summary>,function(loop-unroll)' -pgso=false | FileCheck -check-prefix=NPGSO %s5 6 7;///////////////////// TEST 1 //////////////////////////////8 9; This test shows that the loop is unrolled according to the specified10; unroll factor.11 12define void @Test1() nounwind {13entry:14  br label %loop15 16loop:17  %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]18  %inc = add i32 %iv, 119  %exitcnd = icmp uge i32 %inc, 102420  br i1 %exitcnd, label %exit, label %loop21 22exit:23  ret void24}25 26; CHECK_COUNT4-LABEL: @Test127; CHECK_COUNT4:      phi28; CHECK_COUNT4-NEXT: add{{.*}}, 429; CHECK_COUNT4-NEXT: icmp30 31 32;///////////////////// TEST 2 //////////////////////////////33 34; This test shows that with optnone attribute, the loop is not unrolled35; even if an unroll factor was specified.36 37define void @Test2() nounwind optnone noinline {38entry:39  br label %loop40 41loop:42  %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]43  %inc = add i32 %iv, 144  %exitcnd = icmp uge i32 %inc, 102445  br i1 %exitcnd, label %exit, label %loop46 47exit:48  ret void49}50 51; CHECK_COUNT4-LABEL: @Test252; CHECK_COUNT4:      phi53; CHECK_COUNT4-NEXT: add54; CHECK_COUNT4-NEXT: icmp55 56 57;///////////////////// TEST 3 //////////////////////////////58 59; This test shows that this loop is fully unrolled by default.60 61@tab = common global [24 x i32] zeroinitializer, align 462 63define i32 @Test3() {64entry:65  br label %for.body66 67for.body:                                         ; preds = %for.body, %entry68  %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]69  %arrayidx = getelementptr inbounds [24 x i32], ptr @tab, i32 0, i32 %i.0570  store i32 %i.05, ptr %arrayidx, align 471  %inc = add nuw nsw i32 %i.05, 172  %exitcond = icmp eq i32 %inc, 2473  br i1 %exitcond, label %for.end, label %for.body74 75for.end:                                          ; preds = %for.body76  ret i32 4277}78 79; CHECK_NOCOUNT-LABEL: @Test380; CHECK_NOCOUNT:      store81; CHECK_NOCOUNT-NEXT: store82; CHECK_NOCOUNT-NEXT: store83; CHECK_NOCOUNT-NEXT: store84; CHECK_NOCOUNT-NEXT: store85; CHECK_NOCOUNT-NEXT: store86; CHECK_NOCOUNT-NEXT: store87; CHECK_NOCOUNT-NEXT: store88; CHECK_NOCOUNT-NEXT: store89; CHECK_NOCOUNT-NEXT: store90; CHECK_NOCOUNT-NEXT: store91; CHECK_NOCOUNT-NEXT: store92; CHECK_NOCOUNT-NEXT: store93; CHECK_NOCOUNT-NEXT: store94; CHECK_NOCOUNT-NEXT: store95; CHECK_NOCOUNT-NEXT: store96; CHECK_NOCOUNT-NEXT: store97; CHECK_NOCOUNT-NEXT: store98; CHECK_NOCOUNT-NEXT: store99; CHECK_NOCOUNT-NEXT: store100; CHECK_NOCOUNT-NEXT: store101; CHECK_NOCOUNT-NEXT: store102; CHECK_NOCOUNT-NEXT: store103; CHECK_NOCOUNT-NEXT: store104; CHECK_NOCOUNT-NEXT: ret105 106 107;///////////////////// TEST 4 //////////////////////////////108 109; This test shows that with optsize attribute, this loop is not unrolled.110 111define i32 @Test4() optsize {112entry:113  br label %for.body114 115for.body:                                         ; preds = %for.body, %entry116  %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]117  %arrayidx = getelementptr inbounds [24 x i32], ptr @tab, i32 0, i32 %i.05118  store i32 %i.05, ptr %arrayidx, align 4119  %inc = add nuw nsw i32 %i.05, 1120  %exitcond = icmp eq i32 %inc, 24121  br i1 %exitcond, label %for.end, label %for.body122 123for.end:                                          ; preds = %for.body124  ret i32 42125}126 127; CHECK_NOCOUNT-LABEL: @Test4128; CHECK_NOCOUNT:      phi129; CHECK_NOCOUNT:      icmp130 131;///////////////////// TEST 5 //////////////////////////////132 133; This test shows that with PGO, this loop is cold and not unrolled.134 135define i32 @Test5() !prof !14 {136entry:137  br label %for.body138 139for.body:                                         ; preds = %for.body, %entry140  %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]141  %arrayidx = getelementptr inbounds [24 x i32], ptr @tab, i32 0, i32 %i.05142  store i32 %i.05, ptr %arrayidx, align 4143  %inc = add nuw nsw i32 %i.05, 1144  %exitcond = icmp eq i32 %inc, 24145  br i1 %exitcond, label %for.end, label %for.body146 147for.end:                                          ; preds = %for.body148  ret i32 42149}150 151; PGSO-LABEL: @Test5152; PGSO:      phi153; PGSO:      icmp154; NPGSO-LABEL: @Test5155; NPGSO-NOT:      phi156; NPGSO-NOT:      icmp157 158;///////////////////// TEST 6 //////////////////////////////159 160; This test tests that unroll hints take precedence over PGSO and that this loop161; gets unrolled even though it's cold.162 163define i32 @Test6() !prof !14 {164entry:165  br label %for.body166 167for.body:                                         ; preds = %for.body, %entry168  %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]169  %arrayidx = getelementptr inbounds [24 x i32], ptr @tab, i32 0, i32 %i.05170  store i32 %i.05, ptr %arrayidx, align 4171  %inc = add nuw nsw i32 %i.05, 1172  %exitcond = icmp eq i32 %inc, 24173  br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !15174 175for.end:                                          ; preds = %for.body176  ret i32 42177}178 179; PGSO-LABEL: @Test6180; PGSO:      store181; PGSO:      store182; PGSO:      store183; PGSO:      store184; NPGSO-LABEL: @Test6185; NPGSO:      store186; NPGSO:      store187; NPGSO:      store188; NPGSO:      store189 190!llvm.module.flags = !{!0}191!0 = !{i32 1, !"ProfileSummary", !1}192!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}193!2 = !{!"ProfileFormat", !"InstrProf"}194!3 = !{!"TotalCount", i64 10000}195!4 = !{!"MaxCount", i64 10}196!5 = !{!"MaxInternalCount", i64 1}197!6 = !{!"MaxFunctionCount", i64 1000}198!7 = !{!"NumCounts", i64 3}199!8 = !{!"NumFunctions", i64 3}200!9 = !{!"DetailedSummary", !10}201!10 = !{!11, !12, !13}202!11 = !{i32 10000, i64 100, i32 1}203!12 = !{i32 999000, i64 100, i32 1}204!13 = !{i32 999999, i64 1, i32 2}205!14 = !{!"function_entry_count", i64 0}206!15 = !{!15, !16}207!16 = !{!"llvm.loop.unroll.count", i32 4}208