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
6 declare i32 @strcmp(ptr nocapture, ptr nocapture)
7 declare i32 @strncmp(ptr nocapture, ptr nocapture, i64)
9 @s1 = constant [1 x i8] c"\00", align 1
10 @s2n = constant [2 x i8] c"aa", align 1
11 @s3 = constant [3 x i8] c"aa\00", align 1
12 @s4 = constant [4 x i8] c"aab\00", align 1
15 define i1 @test_strncmp_0(ptr %s) {
17 %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 1)
18 %cmp = icmp eq i32 %call, 0
21 ; CHECK-LABEL: @test_strncmp_0(
25 define i1 @test_strncmp_1(ptr %s) {
27 %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 2)
28 %cmp = icmp eq i32 %call, 0
31 ; CHECK-LABEL: @test_strncmp_1(
37 define i1 @test_strncmp_1_dereferenceable(ptr dereferenceable(2) %s) {
39 %call = tail call i32 @strncmp(ptr nonnull %s, ptr nonnull dereferenceable(3) @s3, i64 2)
40 %cmp = icmp eq i32 %call, 0
43 ; CHECK-LABEL: @test_strncmp_1_dereferenceable(
46 define i32 @test_strncmp_1_not_comparision(ptr %s) {
48 %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 2)
51 ; CHECK-LABEL: @test_strncmp_1_not_comparision(
55 define i1 @test_strncmp_2(ptr %s) {
57 %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 3)
58 %cmp = icmp eq i32 %call, 0
61 ; CHECK-LABEL: @test_strncmp_2(
67 ; strncmp(s, "aab", 3)
68 define i1 @test_strncmp_3(ptr %s) {
70 %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(4) @s4, i64 3)
71 %cmp = icmp eq i32 %call, 0
74 ; CHECK-LABEL: @test_strncmp_3(
77 ; strncmp(s, "aab", 4)
78 define i1 @test_strncmp_4(ptr %s) {
80 %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(4) @s4, i64 4)
81 %cmp = icmp eq i32 %call, 0
84 ; CHECK-LABEL: @test_strncmp_4(
88 define i1 @test_strncmp_5(ptr %s) {
90 %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 2)
91 %cmp = icmp eq i32 %call, 0
94 ; CHECK-LABEL: @test_strncmp_5(
97 ; char s2[] = {'a', 'a'}
99 define i1 @test_strncmp_6(ptr %s1) {
101 %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s1, ptr nonnull dereferenceable(2) @s2n, i64 2)
102 %cmp = icmp eq i32 %call, 0
105 ; CHECK-LABEL: @test_strncmp_6(
108 ; char s2[] = {'a', 'a'}
110 define i1 @test_strncmp_7(ptr %s) {
112 %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(2) @s2n, i64 3)
113 %cmp = icmp eq i32 %call, 0
116 ; CHECK-LABEL: @test_strncmp_7(
120 define i1 @test_strcmp_0(ptr %s) {
122 %call = tail call i32 @strcmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(1) @s1)
123 %cmp = icmp eq i32 %call, 0
126 ; CHECK-LABEL: @test_strcmp_0(
130 define i1 @test_strcmp_1(ptr %s) {
132 %call = tail call i32 @strcmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3)
133 %cmp = icmp eq i32 %call, 0
136 ; CHECK-LABEL: @test_strcmp_1(
140 define i1 @test_strcmp_2(ptr %s) {
142 %call = tail call i32 @strcmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(4) @s4)
143 %cmp = icmp eq i32 %call, 0
146 ; CHECK-LABEL: @test_strcmp_2(