1; RUN: llvm-profdata merge %S/Inputs/select_hash_conflict.proftext -o %t.profdata
2; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-select=true -S | FileCheck %s
3; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instr-select=true -S | FileCheck %s
4
5target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8@a = common dso_local local_unnamed_addr global [16 x i32] zeroinitializer, align 16
9@c0 = common dso_local local_unnamed_addr global i8 0, align 1
10@c1 = common dso_local local_unnamed_addr global i8 0, align 1
11@c2 = common dso_local local_unnamed_addr global i8 0, align 1
12@c3 = common dso_local local_unnamed_addr global i8 0, align 1
13@c4 = common dso_local local_unnamed_addr global i8 0, align 1
14@c5 = common dso_local local_unnamed_addr global i8 0, align 1
15@c6 = common dso_local local_unnamed_addr global i8 0, align 1
16@c7 = common dso_local local_unnamed_addr global i8 0, align 1
17@c8 = common dso_local local_unnamed_addr global i8 0, align 1
18@c9 = common dso_local local_unnamed_addr global i8 0, align 1
19@c10 = common dso_local local_unnamed_addr global i8 0, align 1
20@c11 = common dso_local local_unnamed_addr global i8 0, align 1
21@c12 = common dso_local local_unnamed_addr global i8 0, align 1
22@c13 = common dso_local local_unnamed_addr global i8 0, align 1
23@c14 = common dso_local local_unnamed_addr global i8 0, align 1
24@c15 = common dso_local local_unnamed_addr global i8 0, align 1
25
26define i32 @foo(i32 %n) {
27entry:
28  %0 = load i8, i8* @c0, align 1
29  %tobool = icmp eq i8 %0, 0
30  %cond = select i1 %tobool, i32 2, i32 1
31  store i32 %cond, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 0), align 16
32  %1 = load i8, i8* @c1, align 1
33  %tobool2 = icmp eq i8 %1, 0
34  %cond3 = select i1 %tobool2, i32 2, i32 1
35  store i32 %cond3, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 1), align 4
36  %2 = load i8, i8* @c2, align 1
37  %tobool5 = icmp eq i8 %2, 0
38  %cond6 = select i1 %tobool5, i32 2, i32 1
39  store i32 %cond6, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 2), align 8
40  %3 = load i8, i8* @c3, align 1
41  %tobool8 = icmp eq i8 %3, 0
42  %cond9 = select i1 %tobool8, i32 2, i32 1
43  store i32 %cond9, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 3), align 4
44  %4 = load i8, i8* @c4, align 1
45  %tobool11 = icmp eq i8 %4, 0
46  %cond12 = select i1 %tobool11, i32 2, i32 1
47  store i32 %cond12, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 4), align 16
48  %5 = load i8, i8* @c5, align 1
49  %tobool14 = icmp eq i8 %5, 0
50  %cond15 = select i1 %tobool14, i32 2, i32 1
51  store i32 %cond15, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 5), align 4
52  %6 = load i8, i8* @c6, align 1
53  %tobool17 = icmp eq i8 %6, 0
54  %cond18 = select i1 %tobool17, i32 2, i32 1
55  store i32 %cond18, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 6), align 8
56  %7 = load i8, i8* @c7, align 1
57  %tobool20 = icmp eq i8 %7, 0
58  %cond21 = select i1 %tobool20, i32 2, i32 1
59  store i32 %cond21, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 7), align 4
60  %8 = load i8, i8* @c8, align 1
61  %tobool23 = icmp eq i8 %8, 0
62  %cond24 = select i1 %tobool23, i32 2, i32 1
63  store i32 %cond24, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 8), align 16
64  %9 = load i8, i8* @c9, align 1
65  %tobool26 = icmp eq i8 %9, 0
66  %cond27 = select i1 %tobool26, i32 2, i32 1
67  store i32 %cond27, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 9), align 4
68  %10 = load i8, i8* @c10, align 1
69  %tobool29 = icmp eq i8 %10, 0
70  %cond30 = select i1 %tobool29, i32 2, i32 1
71  store i32 %cond30, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 10), align 8
72  %11 = load i8, i8* @c11, align 1
73  %tobool32 = icmp eq i8 %11, 0
74  %cond33 = select i1 %tobool32, i32 2, i32 1
75  store i32 %cond33, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 11), align 4
76  %12 = load i8, i8* @c12, align 1
77  %tobool35 = icmp eq i8 %12, 0
78  %cond36 = select i1 %tobool35, i32 2, i32 1
79  store i32 %cond36, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 12), align 16
80  %13 = load i8, i8* @c13, align 1
81  %tobool38 = icmp eq i8 %13, 0
82  %cond39 = select i1 %tobool38, i32 2, i32 1
83  store i32 %cond39, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 13), align 4
84  %14 = load i8, i8* @c14, align 1
85  %tobool41 = icmp eq i8 %14, 0
86  %cond42 = select i1 %tobool41, i32 2, i32 1
87  store i32 %cond42, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 14), align 8
88  %15 = load i8, i8* @c15, align 1
89  %tobool44 = icmp eq i8 %15, 0
90  %cond45 = select i1 %tobool44, i32 2, i32 1
91  store i32 %cond45, i32* getelementptr inbounds ([16 x i32], [16 x i32]* @a, i64 0, i64 15), align 4
92  ret i32 %n
93}
94; CHECK-LABEL: define i32 @foo(i32 %n)
95; We should skip the profile.
96; CHECK-NOT: %{{.*}} = select i1 %{{.*}}, i32 2, i32 1, !prof
97
98