brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 0cc5e3f Raw
148 lines · plain
1; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=3 < %s | FileCheck --check-prefixes=CHECK,TH-3 %s2; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=2 < %s | FileCheck --check-prefixes=CHECK,TH-2 %s3; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=1 < %s | FileCheck --check-prefixes=CHECK,TH-1 %s4; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=0 < %s | FileCheck --check-prefixes=CHECK,TH-0 %s5 6declare i32 @strcmp(ptr nocapture, ptr nocapture)7declare i32 @strncmp(ptr nocapture, ptr nocapture, i64)8 9@s1 = constant [1 x i8] c"\00", align 110@s2n = constant [2 x i8] c"aa", align 111@s3 = constant [3 x i8] c"aa\00", align 112@s4 = constant [4 x i8] c"aab\00", align 113 14; strncmp(s, "aa", 1)15define i1 @test_strncmp_0(ptr %s) {16entry:17  %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 1)18  %cmp = icmp eq i32 %call, 019  ret i1 %cmp20}21; CHECK-LABEL: @test_strncmp_0(22; CHECK: @strncmp23 24; strncmp(s, "aa", 2)25define i1 @test_strncmp_1(ptr %s) {26entry:27  %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 2)28  %cmp = icmp eq i32 %call, 029  ret i1 %cmp30}31; CHECK-LABEL: @test_strncmp_1(32; TH-3-NOT: @strncmp33; TH-2-NOT: @strncmp34; TH-1: @strncmp35; TH-0: @strncmp36 37define i1 @test_strncmp_1_dereferenceable(ptr dereferenceable(2) %s) {38entry:39  %call = tail call i32 @strncmp(ptr nonnull %s, ptr nonnull dereferenceable(3) @s3, i64 2)40  %cmp = icmp eq i32 %call, 041  ret i1 %cmp42}43; CHECK-LABEL: @test_strncmp_1_dereferenceable(44; CHECK: @strncmp45 46define i32 @test_strncmp_1_not_comparision(ptr %s) {47entry:48  %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 2)49  ret i32 %call50}51; CHECK-LABEL: @test_strncmp_1_not_comparision(52; CHECK: @strncmp53 54; strncmp(s, "aa", 3)55define i1 @test_strncmp_2(ptr %s) {56entry:57  %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 3)58  %cmp = icmp eq i32 %call, 059  ret i1 %cmp60}61; CHECK-LABEL: @test_strncmp_2(62; TH-3-NOT: @strncmp63; TH-2: @strncmp64; TH-1: @strncmp65; TH-0: @strncmp66 67; strncmp(s, "aab", 3)68define i1 @test_strncmp_3(ptr %s) {69entry:70  %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(4) @s4, i64 3)71  %cmp = icmp eq i32 %call, 072  ret i1 %cmp73}74; CHECK-LABEL: @test_strncmp_3(75; TH-3-NOT: @strncmp76 77; strncmp(s, "aab", 4)78define i1 @test_strncmp_4(ptr %s) {79entry:80  %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(4) @s4, i64 4)81  %cmp = icmp eq i32 %call, 082  ret i1 %cmp83}84; CHECK-LABEL: @test_strncmp_4(85; TH-3: @strncmp86 87; strncmp(s, "aa", 2)88define i1 @test_strncmp_5(ptr %s) {89entry:90  %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3, i64 2)91  %cmp = icmp eq i32 %call, 092  ret i1 %cmp93}94; CHECK-LABEL: @test_strncmp_5(95; TH-3-NOT: @strncmp96 97; char s2[] = {'a', 'a'}98; strncmp(s1, s2, 2)99define i1 @test_strncmp_6(ptr %s1) {100entry:101  %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s1, ptr nonnull dereferenceable(2) @s2n, i64 2)102  %cmp = icmp eq i32 %call, 0103  ret i1 %cmp104}105; CHECK-LABEL: @test_strncmp_6(106; TH-3-NOT: @strncmp107 108; char s2[] = {'a', 'a'}109; strncmp(s, s2, 3)110define i1 @test_strncmp_7(ptr %s) {111entry:112  %call = tail call i32 @strncmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(2) @s2n, i64 3)113  %cmp = icmp eq i32 %call, 0114  ret i1 %cmp115}116; CHECK-LABEL: @test_strncmp_7(117; CHECK: @strncmp118 119; strcmp(s, "")120define i1 @test_strcmp_0(ptr %s) {121entry:122  %call = tail call i32 @strcmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(1) @s1)123  %cmp = icmp eq i32 %call, 0124  ret i1 %cmp125}126; CHECK-LABEL: @test_strcmp_0(127; CHECK: @strcmp128 129; strcmp(s, "aa")130define i1 @test_strcmp_1(ptr %s) {131entry:132  %call = tail call i32 @strcmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(3) @s3)133  %cmp = icmp eq i32 %call, 0134  ret i1 %cmp135}136; CHECK-LABEL: @test_strcmp_1(137; TH-3-NOT: @strcmp138 139; strcmp(s, "aab")140define i1 @test_strcmp_2(ptr %s) {141entry:142  %call = tail call i32 @strcmp(ptr nonnull dereferenceable(1) %s, ptr nonnull dereferenceable(4) @s4)143  %cmp = icmp eq i32 %call, 0144  ret i1 %cmp145}146; CHECK-LABEL: @test_strcmp_2(147; TH-3: @strcmp148