1 ; RUN: opt -mtriple=arm-arm-none-eabi -consthoist -S < %s | FileCheck %s
2 ; RUN: opt -mtriple=arm-arm-none-eabi -consthoist -pgso -S < %s -enable-new-pm=0 | FileCheck %s -check-prefix=PGSO
3 ; RUN: opt -mtriple=arm-arm-none-eabi -passes='require<profile-summary>,consthoist' -pgso -S < %s | FileCheck %s -check-prefix=PGSO
4 ; RUN: opt -mtriple=arm-arm-none-eabi -consthoist -pgso=false -S < %s | FileCheck %s -check-prefix=NPGSO
6 ; There are different candidates here for the base constant: 1073876992 and
7 ; 1073876996. But we don't want to see the latter because it results in
10 define void @foo() #0 {
13 ; CHECK-NOT: [[CONST1:%const_mat[0-9]*]] = add i32 %const, -4
14 ; CHECK-LABEL: @foo_pgso
15 %0 = load volatile i32, i32* inttoptr (i32 1073876992 to i32*), align 4096
17 store volatile i32 %or, i32* inttoptr (i32 1073876992 to i32*), align 4096
18 %1 = load volatile i32, i32* inttoptr (i32 1073876996 to i32*), align 4
19 %and = and i32 %1, -117506048
20 store volatile i32 %and, i32* inttoptr (i32 1073876996 to i32*), align 4
21 %2 = load volatile i32, i32* inttoptr (i32 1073876992 to i32*), align 4096
22 %and1 = and i32 %2, -17367041
23 store volatile i32 %and1, i32* inttoptr (i32 1073876996 to i32*), align 4096
24 %3 = load volatile i32, i32* inttoptr (i32 1073876992 to i32*), align 4096
25 %and2 = and i32 %3, -262145
26 store volatile i32 %and2, i32* inttoptr (i32 1073876992 to i32*), align 4096
27 %4 = load volatile i32, i32* inttoptr (i32 1073876996 to i32*), align 4
28 %and3 = and i32 %4, -8323073
29 store volatile i32 %and3, i32* inttoptr (i32 1073876996 to i32*), align 4
30 store volatile i32 10420224, i32* inttoptr (i32 1073877000 to i32*), align 8
31 %5 = load volatile i32, i32* inttoptr (i32 1073876996 to i32*), align 4096
32 %or4 = or i32 %5, 65536
33 store volatile i32 %or4, i32* inttoptr (i32 1073876996 to i32*), align 4096
34 %6 = load volatile i32, i32* inttoptr (i32 1073881088 to i32*), align 8192
35 %or6.i.i = or i32 %6, 16
36 store volatile i32 %or6.i.i, i32* inttoptr (i32 1073881088 to i32*), align 8192
37 %7 = load volatile i32, i32* inttoptr (i32 1073881088 to i32*), align 8192
38 %and7.i.i = and i32 %7, -4
39 store volatile i32 %and7.i.i, i32* inttoptr (i32 1073881088 to i32*), align 8192
40 %8 = load volatile i32, i32* inttoptr (i32 1073881088 to i32*), align 8192
41 %or8.i.i = or i32 %8, 2
42 store volatile i32 %or8.i.i, i32* inttoptr (i32 1073881088 to i32*), align 8192
46 attributes #0 = { minsize norecurse nounwind optsize readnone uwtable }
48 define void @foo_pgso() #1 !prof !14 {
50 ; PGSO-LABEL: @foo_pgso
51 ; PGSO-NOT: [[CONST2:%const_mat[0-9]*]] = add i32 %const, -4
52 ; NPGSO-LABEL: @foo_pgso
53 ; NPGSO: [[CONST2:%const_mat[0-9]*]] = add i32 %const, -4
54 %0 = load volatile i32, i32* inttoptr (i32 1073876992 to i32*), align 4096
56 store volatile i32 %or, i32* inttoptr (i32 1073876992 to i32*), align 4096
57 %1 = load volatile i32, i32* inttoptr (i32 1073876996 to i32*), align 4
58 %and = and i32 %1, -117506048
59 store volatile i32 %and, i32* inttoptr (i32 1073876996 to i32*), align 4
60 %2 = load volatile i32, i32* inttoptr (i32 1073876992 to i32*), align 4096
61 %and1 = and i32 %2, -17367041
62 store volatile i32 %and1, i32* inttoptr (i32 1073876996 to i32*), align 4096
63 %3 = load volatile i32, i32* inttoptr (i32 1073876992 to i32*), align 4096
64 %and2 = and i32 %3, -262145
65 store volatile i32 %and2, i32* inttoptr (i32 1073876992 to i32*), align 4096
66 %4 = load volatile i32, i32* inttoptr (i32 1073876996 to i32*), align 4
67 %and3 = and i32 %4, -8323073
68 store volatile i32 %and3, i32* inttoptr (i32 1073876996 to i32*), align 4
69 store volatile i32 10420224, i32* inttoptr (i32 1073877000 to i32*), align 8
70 %5 = load volatile i32, i32* inttoptr (i32 1073876996 to i32*), align 4096
71 %or4 = or i32 %5, 65536
72 store volatile i32 %or4, i32* inttoptr (i32 1073876996 to i32*), align 4096
73 %6 = load volatile i32, i32* inttoptr (i32 1073881088 to i32*), align 8192
74 %or6.i.i = or i32 %6, 16
75 store volatile i32 %or6.i.i, i32* inttoptr (i32 1073881088 to i32*), align 8192
76 %7 = load volatile i32, i32* inttoptr (i32 1073881088 to i32*), align 8192
77 %and7.i.i = and i32 %7, -4
78 store volatile i32 %and7.i.i, i32* inttoptr (i32 1073881088 to i32*), align 8192
79 %8 = load volatile i32, i32* inttoptr (i32 1073881088 to i32*), align 8192
80 %or8.i.i = or i32 %8, 2
81 store volatile i32 %or8.i.i, i32* inttoptr (i32 1073881088 to i32*), align 8192
85 attributes #1 = { norecurse nounwind readnone uwtable } ; no optsize or minsize
87 !llvm.module.flags = !{!0}
88 !0 = !{i32 1, !"ProfileSummary", !1}
89 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
90 !2 = !{!"ProfileFormat", !"InstrProf"}
91 !3 = !{!"TotalCount", i64 10000}
92 !4 = !{!"MaxCount", i64 10}
93 !5 = !{!"MaxInternalCount", i64 1}
94 !6 = !{!"MaxFunctionCount", i64 1000}
95 !7 = !{!"NumCounts", i64 3}
96 !8 = !{!"NumFunctions", i64 3}
97 !9 = !{!"DetailedSummary", !10}
98 !10 = !{!11, !12, !13}
99 !11 = !{i32 10000, i64 100, i32 1}
100 !12 = !{i32 999000, i64 100, i32 1}
101 !13 = !{i32 999999, i64 1, i32 2}
102 !14 = !{!"function_entry_count", i64 0}