xref: /llvm-project/llvm/test/Transforms/LoopVectorize/check-prof-info.ll (revision 7d7577256b76e4293f455b8093504d5f7044ab4b)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -passes="print<block-freq>,loop-vectorize" -force-vector-width=4 -force-vector-interleave=1 -S < %s |  FileCheck %s
3; RUN: opt -passes="print<block-freq>,loop-vectorize" -force-vector-width=4 -force-vector-interleave=4 -S < %s |  FileCheck %s -check-prefix=CHECK-MASKED
4
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6
7@a = dso_local global [1024 x i32] zeroinitializer, align 16
8@b = dso_local global [1024 x i32] zeroinitializer, align 16
9
10; Check correctness of profile info for vectorization without epilog.
11; Function Attrs: nofree norecurse nounwind uwtable
12define dso_local void @_Z3foov() local_unnamed_addr #0 {
13; CHECK-LABEL: @_Z3foov(
14; CHECK:  [[VECTOR_BODY:vector\.body]]:
15; CHECK:    br i1 [[TMP:%.*]], label [[MIDDLE_BLOCK:%.*]], label %[[VECTOR_BODY]], !prof [[LP1_255:\!.*]],
16; CHECK:  [[FOR_BODY:for\.body]]:
17; CHECK:    br i1 [[EXITCOND:%.*]], label [[FOR_END_LOOPEXIT:%.*]], label %[[FOR_BODY]], !prof [[LP0_0:\!.*]],
18; CHECK-MASKED:  [[VECTOR_BODY:vector\.body]]:
19; CHECK-MASKED:    br i1 [[TMP:%.*]], label [[MIDDLE_BLOCK:%.*]], label %[[VECTOR_BODY]], !prof [[LP1_63:\!.*]],
20; CHECK-MASKED:  [[FOR_BODY:for\.body]]:
21; CHECK-MASKED:    br i1 [[EXITCOND:%.*]], label [[FOR_END_LOOPEXIT:%.*]], label %[[FOR_BODY]], !prof [[LP0_0:\!.*]],
22;
23entry:
24  br label %for.body
25
26for.cond.cleanup:                                 ; preds = %for.body
27  ret void
28
29for.body:                                         ; preds = %for.body, %entry
30  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
31  %arrayidx = getelementptr inbounds [1024 x i32], ptr @b, i64 0, i64 %indvars.iv
32  %0 = load i32, ptr %arrayidx, align 4, !tbaa !2
33  %1 = trunc i64 %indvars.iv to i32
34  %mul = mul nsw i32 %0, %1
35  %arrayidx2 = getelementptr inbounds [1024 x i32], ptr @a, i64 0, i64 %indvars.iv
36  %2 = load i32, ptr %arrayidx2, align 4, !tbaa !2
37  %add = add nsw i32 %2, %mul
38  store i32 %add, ptr %arrayidx2, align 4, !tbaa !2
39  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
40  %exitcond = icmp eq i64 %indvars.iv.next, 1024
41  br i1 %exitcond, label %for.cond.cleanup, label %for.body, !prof !6
42}
43
44; Check correctness of profile info for vectorization with epilog.
45; Function Attrs: nofree norecurse nounwind uwtable
46define dso_local void @_Z3foo2v() local_unnamed_addr #0 {
47; CHECK-LABEL: @_Z3foo2v(
48; CHECK:  [[VECTOR_BODY:vector\.body]]:
49; CHECK:    br i1 [[TMP:%.*]], label [[MIDDLE_BLOCK:%.*]], label %[[VECTOR_BODY]], !prof [[LP1_255:\!.*]],
50; CHECK:  [[FOR_BODY:for\.body]]:
51; CHECK:    br i1 [[EXITCOND:%.*]], label [[FOR_END_LOOPEXIT:%.*]], label %[[FOR_BODY]], !prof [[LP1_2:\!.*]],
52; CHECK-MASKED:  [[VECTOR_BODY:vector\.body]]:
53; CHECK-MASKED:    br i1 [[TMP:%.*]], label [[MIDDLE_BLOCK:%.*]], label %[[VECTOR_BODY]], !prof [[LP1_63:\!.*]],
54; CHECK-MASKED:  [[FOR_BODY:for\.body]]:
55; CHECK-MASKED:    br i1 [[EXITCOND:%.*]], label [[FOR_END_LOOPEXIT:%.*]], label %[[FOR_BODY]], !prof [[LP1_2:\!.*]],
56;
57entry:
58  br label %for.body
59
60for.cond.cleanup:                                 ; preds = %for.body
61  ret void
62
63for.body:                                         ; preds = %for.body, %entry
64  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
65  %arrayidx = getelementptr inbounds [1024 x i32], ptr @b, i64 0, i64 %indvars.iv
66  %0 = load i32, ptr %arrayidx, align 4, !tbaa !2
67  %1 = trunc i64 %indvars.iv to i32
68  %mul = mul nsw i32 %0, %1
69  %arrayidx2 = getelementptr inbounds [1024 x i32], ptr @a, i64 0, i64 %indvars.iv
70  %2 = load i32, ptr %arrayidx2, align 4, !tbaa !2
71  %add = add nsw i32 %2, %mul
72  store i32 %add, ptr %arrayidx2, align 4, !tbaa !2
73  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
74  %exitcond = icmp eq i64 %indvars.iv.next, 1027
75  br i1 %exitcond, label %for.cond.cleanup, label %for.body, !prof !7
76}
77
78attributes #0 = { "use-soft-float"="false" }
79
80!llvm.module.flags = !{!0}
81!llvm.ident = !{!1}
82
83; CHECK: [[LP1_255]] = !{!"branch_weights", i32 1, i32 255}
84; CHECK: [[LP0_0]] = !{!"branch_weights", i32 0, i32 0}
85; CHECK-MASKED: [[LP1_63]] = !{!"branch_weights", i32 1, i32 63}
86; CHECK-MASKED: [[LP0_0]] = !{!"branch_weights", i32 0, i32 0}
87; CHECK: [[LP1_2]] = !{!"branch_weights", i32 1, i32 2}
88
89!0 = !{i32 1, !"wchar_size", i32 4}
90!1 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project c292b5b5e059e6ce3e6449e6827ef7e1037c21c4)"}
91!2 = !{!3, !3, i64 0}
92!3 = !{!"int", !4, i64 0}
93!4 = !{!"omnipotent char", !5, i64 0}
94!5 = !{!"Simple C++ TBAA"}
95!6 = !{!"branch_weights", i32 1, i32 1023}
96!7 = !{!"branch_weights", i32 1, i32 1026}
97