126 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 22 3; RUN: opt < %s -passes='pgo-force-function-attrs,function(loop-mssa(simple-loop-unswitch<nontrivial>))' -pgo-kind=pgo-instr-use-pipeline -pgo-cold-func-opt=optsize -S | FileCheck %s4; RUN: opt < %s -passes='pgo-force-function-attrs,function(loop-mssa(simple-loop-unswitch<nontrivial>))' -pgo-kind=pgo-instr-use-pipeline -pgo-cold-func-opt=minsize -S | FileCheck %s5 6;; Check that non-trivial loop unswitching is not applied to a cold loop in a7;; cold loop nest.8 9;; IR was generated from the following loop nest, profiled when called10;; with M=0 and N=0.11;; void function(bool cond, int M, int N, int * A, int *B, int *C) {12;; for (unsigned j = 0; j < M; j++)13;; for (unsigned i=0; i < N; i++) {14;; A[i] = B[i] + C[i];15;; if (cond) do_something();16;; }17;; }18 19define void @_Z11functionbiiPiS_S_(i1 %cond, i32 %M, i32 %N, ptr %A, ptr %B, ptr %C) !prof !36 {20; CHECK-LABEL: define void @_Z11functionbiiPiS_S_21; CHECK-SAME: (i1 [[COND:%.*]], i32 [[M:%.*]], i32 [[N:%.*]], ptr [[A:%.*]], ptr [[B:%.*]], ptr [[C:%.*]]) {{.*}}{22; CHECK-NEXT: entry:23; CHECK-NEXT: [[CMP19_NOT:%.*]] = icmp eq i32 [[M]], 024; CHECK-NEXT: br i1 [[CMP19_NOT]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_COND1_PREHEADER_LR_PH:%.*]], !prof [[PROF17:![0-9]+]]25; CHECK: for.cond1.preheader.lr.ph:26; CHECK-NEXT: [[CMP217_NOT:%.*]] = icmp eq i32 [[N]], 027; CHECK-NEXT: br label [[FOR_COND1_PREHEADER:%.*]]28; CHECK: for.cond1.preheader:29; CHECK-NEXT: [[J_020:%.*]] = phi i32 [ 0, [[FOR_COND1_PREHEADER_LR_PH]] ], [ [[INC10:%.*]], [[FOR_COND_CLEANUP3:%.*]] ]30; CHECK-NEXT: br i1 [[CMP217_NOT]], label [[FOR_COND_CLEANUP3]], label [[FOR_BODY4_PREHEADER:%.*]]31; CHECK: for.body4.preheader:32; CHECK-NEXT: br label [[FOR_BODY4:%.*]]33; CHECK: for.cond.cleanup.loopexit:34; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]35; CHECK: for.cond.cleanup:36; CHECK-NEXT: ret void37; CHECK: for.cond.cleanup3.loopexit:38; CHECK-NEXT: br label [[FOR_COND_CLEANUP3]]39; CHECK: for.cond.cleanup3:40; CHECK-NEXT: [[INC10]] = add nuw i32 [[J_020]], 141; CHECK-NEXT: [[EXITCOND22_NOT:%.*]] = icmp eq i32 [[INC10]], [[M]]42; CHECK-NEXT: br i1 [[EXITCOND22_NOT]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_COND1_PREHEADER]], !prof [[PROF17]]43; CHECK: for.body4:44; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_INC:%.*]] ], [ 0, [[FOR_BODY4_PREHEADER]] ]45; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[B]], i64 [[INDVARS_IV]]46; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 447; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds i32, ptr [[C]], i64 [[INDVARS_IV]]48; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX6]], align 449; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP1]], [[TMP0]]50; CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[INDVARS_IV]]51; CHECK-NEXT: store i32 [[ADD]], ptr [[ARRAYIDX8]], align 452; CHECK-NEXT: br i1 [[COND]], label [[IF_THEN:%.*]], label [[FOR_INC]]53; CHECK: if.then:54; CHECK-NEXT: tail call void @_Z12do_somethingv()55; CHECK-NEXT: br label [[FOR_INC]]56; CHECK: for.inc:57; CHECK-NEXT: [[WIDE_TRIP_COUNT:%.*]] = zext i32 [[N]] to i6458; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 159; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[WIDE_TRIP_COUNT]]60; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP3_LOOPEXIT:%.*]], label [[FOR_BODY4]]61;62entry:63 %cmp19.not = icmp eq i32 %M, 064 br i1 %cmp19.not, label %for.cond.cleanup, label %for.cond1.preheader.lr.ph, !prof !3765 66for.cond1.preheader.lr.ph:67 %cmp217.not = icmp eq i32 %N, 068 br label %for.cond1.preheader69 70for.cond1.preheader:71 %j.020 = phi i32 [ 0, %for.cond1.preheader.lr.ph ], [ %inc10, %for.cond.cleanup3 ]72 br i1 %cmp217.not, label %for.cond.cleanup3, label %for.body473 74for.cond.cleanup:75 ret void76 77for.cond.cleanup3:78 %inc10 = add nuw i32 %j.020, 179 %exitcond22.not = icmp eq i32 %inc10, %M80 br i1 %exitcond22.not, label %for.cond.cleanup, label %for.cond1.preheader, !prof !3781 82for.body4:83 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.cond1.preheader ]84 %arrayidx = getelementptr inbounds i32, ptr %B, i64 %indvars.iv85 %0 = load i32, ptr %arrayidx, align 486 %arrayidx6 = getelementptr inbounds i32, ptr %C, i64 %indvars.iv87 %1 = load i32, ptr %arrayidx6, align 488 %add = add nsw i32 %1, %089 %arrayidx8 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv90 store i32 %add, ptr %arrayidx8, align 491 br i1 %cond, label %if.then, label %for.inc92 93if.then:94 tail call void @_Z12do_somethingv()95 br label %for.inc96 97for.inc:98 %wide.trip.count = zext i32 %N to i6499 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1100 %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count101 br i1 %exitcond.not, label %for.cond.cleanup3, label %for.body4102}103 104declare void @_Z12do_somethingv()105 106!llvm.module.flags = !{!6}107 108!6 = !{i32 1, !"ProfileSummary", !7}109!7 = !{!8, !9, !10, !11, !12, !13, !14, !15, !16, !17}110!8 = !{!"ProfileFormat", !"InstrProf"}111!9 = !{!"TotalCount", i64 1002}112!10 = !{!"MaxCount", i64 1000}113!11 = !{!"MaxInternalCount", i64 1000}114!12 = !{!"MaxFunctionCount", i64 1}115!13 = !{!"NumCounts", i64 6}116!14 = !{!"NumFunctions", i64 3}117!15 = !{!"IsPartialProfile", i64 0}118!16 = !{!"PartialProfileRatio", double 0.000000e+00}119!17 = !{!"DetailedSummary", !18}120!18 = !{!19, !31, !34}121!19 = !{i32 10000, i64 1000, i32 1}122!31 = !{i32 999000, i64 1000, i32 1}123!34 = !{i32 999999, i64 1, i32 3}124!36 = !{!"function_entry_count", i64 1}125!37 = !{!"branch_weights", i32 1, i32 0}126