From 07341e3b378099de4aeac7e89f5e48748398d184 Mon Sep 17 00:00:00 2001 From: Ruobing Han Date: Sun, 4 Sep 2022 11:49:51 -0400 Subject: [PATCH] [test] pre-submission for the following SimpleLoopUnswitch update --- .../SimpleLoopUnswitch/PGO-nontrivial-unswitch2.ll | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 llvm/test/Transforms/SimpleLoopUnswitch/PGO-nontrivial-unswitch2.ll diff --git a/llvm/test/Transforms/SimpleLoopUnswitch/PGO-nontrivial-unswitch2.ll b/llvm/test/Transforms/SimpleLoopUnswitch/PGO-nontrivial-unswitch2.ll new file mode 100644 index 0000000..cc3df2f --- /dev/null +++ b/llvm/test/Transforms/SimpleLoopUnswitch/PGO-nontrivial-unswitch2.ll @@ -0,0 +1,77 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py + +; RUN: opt < %s -passes='require,function(loop-mssa(simple-loop-unswitch))' -S | FileCheck %s + +declare i32 @a() +declare i32 @b() + +; Check loops will be applied non-trivial loop unswitch in a non-cold function, +; even loop headers are cold + +define void @f1(i32 %i, i1 %cond, i1 %hot_cond, i1 %cold_cond, i1* %ptr) !prof !0 { +; CHECK-LABEL: @f1( +; CHECK-NEXT: entry: +; CHECK-NEXT: br label [[ENTRY_COLD_LOOP:%.*]] +; CHECK: entry_cold_loop: +; CHECK-NEXT: br i1 [[COLD_COND:%.*]], label [[COLD_LOOP_BEGIN_PREHEADER:%.*]], label [[COLD_LOOP_EXIT:%.*]], !prof [[PROF15:![0-9]+]] +; CHECK: cold_loop_begin.preheader: +; CHECK-NEXT: br label [[COLD_LOOP_BEGIN:%.*]] +; CHECK: cold_loop_begin: +; CHECK-NEXT: br i1 [[COND:%.*]], label [[COLD_LOOP_A:%.*]], label [[COLD_LOOP_B:%.*]] +; CHECK: cold_loop_a: +; CHECK-NEXT: [[TMP0:%.*]] = call i32 @a() +; CHECK-NEXT: br label [[COLD_LOOP_LATCH:%.*]] +; CHECK: cold_loop_b: +; CHECK-NEXT: [[TMP1:%.*]] = call i32 @b() +; CHECK-NEXT: br label [[COLD_LOOP_LATCH]] +; CHECK: cold_loop_latch: +; CHECK-NEXT: [[V2:%.*]] = load i1, i1* [[PTR:%.*]], align 1 +; CHECK-NEXT: br i1 [[V2]], label [[COLD_LOOP_BEGIN]], label [[COLD_LOOP_EXIT_LOOPEXIT:%.*]] +; CHECK: cold_loop_exit.loopexit: +; CHECK-NEXT: br label [[COLD_LOOP_EXIT]] +; CHECK: cold_loop_exit: +; CHECK-NEXT: ret void +; +entry: + br label %entry_cold_loop + +entry_cold_loop: + br i1 %cold_cond, label %cold_loop_begin, label %cold_loop_exit, !prof !16 + +cold_loop_begin: + br i1 %cond, label %cold_loop_a, label %cold_loop_b + +cold_loop_a: + call i32 @a() + br label %cold_loop_latch + +cold_loop_b: + call i32 @b() + br label %cold_loop_latch + +cold_loop_latch: + %v2 = load i1, i1* %ptr + br i1 %v2, label %cold_loop_begin, label %cold_loop_exit + +cold_loop_exit: + ret void +} + +!llvm.module.flags = !{!1} +!0 = !{!"function_entry_count", i64 400} +!1 = !{i32 1, !"ProfileSummary", !2} +!2 = !{!3, !4, !5, !6, !7, !8, !9, !10} +!3 = !{!"ProfileFormat", !"InstrProf"} +!4 = !{!"TotalCount", i64 10000} +!5 = !{!"MaxCount", i64 10} +!6 = !{!"MaxInternalCount", i64 1} +!7 = !{!"MaxFunctionCount", i64 1000} +!8 = !{!"NumCounts", i64 3} +!9 = !{!"NumFunctions", i64 3} +!10 = !{!"DetailedSummary", !11} +!11 = !{!12, !13, !14} +!12 = !{i32 10000, i64 100, i32 1} +!13 = !{i32 999000, i64 100, i32 1} +!14 = !{i32 999999, i64 1, i32 2} +!15 = !{!"branch_weights", i32 100, i32 0} +!16 = !{!"branch_weights", i32 0, i32 100} -- 2.7.4