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