1- ; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=3 < %s | FileCheck %s
2- ; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=2 < %s | FileCheck --check-prefix TH-2 %s
3- ; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=1 < %s | FileCheck --check-prefix TH-1 %s
4- ; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=0 < %s | FileCheck --check-prefix TH-0 %s
1+ ; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=3 < %s | FileCheck --check-prefixes=CHECK,TH-3 %s
2+ ; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=2 < %s | FileCheck --check-prefixes=CHECK, TH-2 %s
3+ ; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=1 < %s | FileCheck --check-prefixes=CHECK, TH-1 %s
4+ ; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=0 < %s | FileCheck --check-prefixes=CHECK, TH-0 %s
55
66declare i32 @strcmp (ptr nocapture , ptr nocapture )
77declare i32 @strncmp (ptr nocapture , ptr nocapture , i64 )
@@ -12,152 +12,136 @@ declare i32 @strncmp(ptr nocapture, ptr nocapture, i64)
1212@s4 = constant [4 x i8 ] c "aab\00 " , align 1
1313
1414; strncmp(s, "aa", 1)
15- define i1 @test_strncmp_0 (i8* nocapture readonly %s ) {
15+ define i1 @test_strncmp_0 (i8* %s ) {
1616entry:
1717 %call = tail call i32 @strncmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (3 ) @s3 , i64 1 )
1818 %cmp = icmp eq i32 %call , 0
1919 ret i1 %cmp
2020}
2121; CHECK-LABEL: @test_strncmp_0(
22- ; CHECK : @strncmp
22+ ; TH-3 : @strncmp
2323
2424; strncmp(s, "aa", 2)
25- define i1 @test_strncmp_1 (i8* nocapture readonly %s ) {
25+ define i1 @test_strncmp_1 (i8* %s ) {
2626entry:
2727 %call = tail call i32 @strncmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (3 ) @s3 , i64 2 )
2828 %cmp = icmp eq i32 %call , 0
2929 ret i1 %cmp
3030}
3131; CHECK-LABEL: @test_strncmp_1(
32- ; CHECK-NOT: @strncmp
33-
34- ; TH-2-LABEL: @test_strncmp_1(
32+ ; TH-3-NOT: @strncmp
3533; TH-2-NOT: @strncmp
36- ; TH-1-LABEL: @test_strncmp_1(
3734; TH-1: @strncmp
38- ; TH-0-LABEL: @test_strncmp_1(
3935; TH-0: @strncmp
4036
41- define i1 @test_strncmp_1_dereferenceable (i8* nocapture readonly dereferenceable (2 ) %s ) {
37+ define i1 @test_strncmp_1_dereferenceable (i8* dereferenceable (2 ) %s ) {
4238entry:
4339 %call = tail call i32 @strncmp (ptr nonnull %s , ptr nonnull dereferenceable (3 ) @s3 , i64 2 )
4440 %cmp = icmp eq i32 %call , 0
4541 ret i1 %cmp
4642}
4743; CHECK-LABEL: @test_strncmp_1_dereferenceable(
48- ; CHECK: @strncmp
49-
50- ; TH-2-LABEL: @test_strncmp_1_dereferenceable(
51- ; TH-1-LABEL: @test_strncmp_1_dereferenceable(
52- ; TH-0-LABEL: @test_strncmp_1_dereferenceable(
44+ ; TH-3: @strncmp
5345
54- define i32 @test_strncmp_1_not_comparision (i8* nocapture readonly %s ) {
46+ define i32 @test_strncmp_1_not_comparision (i8* %s ) {
5547entry:
5648 %call = tail call i32 @strncmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (3 ) @s3 , i64 2 )
5749 ret i32 %call
5850}
5951; CHECK-LABEL: @test_strncmp_1_not_comparision(
60- ; CHECK : @strncmp
52+ ; TH-3 : @strncmp
6153
6254; strncmp(s, "aa", 3)
63- define i1 @test_strncmp_2 (i8* nocapture readonly %s ) {
55+ define i1 @test_strncmp_2 (i8* %s ) {
6456entry:
6557 %call = tail call i32 @strncmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (3 ) @s3 , i64 3 )
6658 %cmp = icmp eq i32 %call , 0
6759 ret i1 %cmp
6860}
6961; CHECK-LABEL: @test_strncmp_2(
70- ; CHECK-NOT: @strncmp
71-
72- ; TH-2-LABEL: @test_strncmp_2(
62+ ; TH-3-NOT: @strncmp
7363; TH-2: @strncmp
74- ; TH-1-LABEL: @test_strncmp_2(
7564; TH-1: @strncmp
76- ; TH-0-LABEL: @test_strncmp_2(
7765; TH-0: @strncmp
7866
7967; strncmp(s, "aab", 3)
80- define i1 @test_strncmp_3 (i8* nocapture readonly %s ) {
68+ define i1 @test_strncmp_3 (i8* %s ) {
8169entry:
8270 %call = tail call i32 @strncmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (4 ) @s4 , i64 3 )
8371 %cmp = icmp eq i32 %call , 0
8472 ret i1 %cmp
8573}
8674; CHECK-LABEL: @test_strncmp_3(
87- ; CHECK-NOT: @strncmp
88-
89- ; TH-2-LABEL: @test_strncmp_3(
90- ; TH-1-LABEL: @test_strncmp_3(
91- ; TH-0-LABEL: @test_strncmp_3(
75+ ; TH-3-NOT: @strncmp
9276
9377; strncmp(s, "aab", 4)
94- define i1 @test_strncmp_4 (i8* nocapture readonly %s ) {
78+ define i1 @test_strncmp_4 (i8* %s ) {
9579entry:
9680 %call = tail call i32 @strncmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (4 ) @s4 , i64 4 )
9781 %cmp = icmp eq i32 %call , 0
9882 ret i1 %cmp
9983}
10084; CHECK-LABEL: @test_strncmp_4(
101- ; CHECK : @strncmp
85+ ; TH-3 : @strncmp
10286
10387; strncmp(s, "aa", 2)
104- define i1 @test_strncmp_5 (i8* nocapture readonly %s ) {
88+ define i1 @test_strncmp_5 (i8* %s ) {
10589entry:
10690 %call = tail call i32 @strncmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (3 ) @s3 , i64 2 )
10791 %cmp = icmp eq i32 %call , 0
10892 ret i1 %cmp
10993}
11094; CHECK-LABEL: @test_strncmp_5(
111- ; CHECK -NOT: @strncmp
95+ ; TH-3 -NOT: @strncmp
11296
11397; char s2[] = {'a', 'a'}
11498; strncmp(s1, s2, 2)
115- define i1 @test_strncmp_6 (i8* nocapture readonly %s1 ) {
99+ define i1 @test_strncmp_6 (i8* %s1 ) {
116100entry:
117101 %call = tail call i32 @strncmp (ptr nonnull dereferenceable (1 ) %s1 , ptr nonnull dereferenceable (3 ) @s2n , i64 2 )
118102 %cmp = icmp eq i32 %call , 0
119103 ret i1 %cmp
120104}
121105; CHECK-LABEL: @test_strncmp_6(
122- ; CHECK -NOT: @strncmp
106+ ; TH-3 -NOT: @strncmp
123107
124108; char s2[] = {'a', 'a'}
125109; strncmp(s1, s2, 3)
126- define i1 @test_strncmp_7 (i8* nocapture readonly %s1 ) {
110+ define i1 @test_strncmp_7 (i8* %s1 ) {
127111entry:
128112 %call = tail call i32 @strncmp (ptr nonnull dereferenceable (1 ) %s1 , ptr nonnull dereferenceable (3 ) @s2n , i64 3 )
129113 %cmp = icmp eq i32 %call , 0
130114 ret i1 %cmp
131115}
132116; CHECK-LABEL: @test_strncmp_7(
133- ; CHECK : @strncmp
117+ ; TH-3 : @strncmp
134118
135119; strcmp(s, "")
136- define i1 @test_strcmp_0 (i8* nocapture readonly %s ) {
120+ define i1 @test_strcmp_0 (i8* %s ) {
137121entry:
138122 %call = tail call i32 @strcmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (1 ) @s1 )
139123 %cmp = icmp eq i32 %call , 0
140124 ret i1 %cmp
141125}
142126; CHECK-LABEL: @test_strcmp_0(
143- ; CHECK : @strcmp
127+ ; TH-3 : @strcmp
144128
145129; strcmp(s, "aa")
146- define i1 @test_strcmp_1 (i8* nocapture readonly %s ) {
130+ define i1 @test_strcmp_1 (i8* %s ) {
147131entry:
148132 %call = tail call i32 @strcmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (3 ) @s3 )
149133 %cmp = icmp eq i32 %call , 0
150134 ret i1 %cmp
151135}
152136; CHECK-LABEL: @test_strcmp_1(
153- ; CHECK -NOT: @strcmp
137+ ; TH-3 -NOT: @strcmp
154138
155139; strcmp(s, "aab")
156- define i1 @test_strcmp_2 (i8* nocapture readonly %s ) {
140+ define i1 @test_strcmp_2 (i8* %s ) {
157141entry:
158142 %call = tail call i32 @strcmp (ptr nonnull dereferenceable (1 ) %s , ptr nonnull dereferenceable (4 ) @s4 )
159143 %cmp = icmp eq i32 %call , 0
160144 ret i1 %cmp
161145}
162146; CHECK-LABEL: @test_strcmp_2(
163- ; CHECK : @strcmp
147+ ; TH-3 : @strcmp
0 commit comments