[llvm] [AggressiveInstCombine] Inline strcmp/strncmp (PR #89371)

Franklin Zhang via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 20:06:34 PDT 2024


================
@@ -0,0 +1,147 @@
+; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=3 < %s | FileCheck --check-prefixes=CHECK,TH-3 %s
+; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=2 < %s | FileCheck --check-prefixes=CHECK,TH-2 %s
+; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=1 < %s | FileCheck --check-prefixes=CHECK,TH-1 %s
+; RUN: opt -S -passes=aggressive-instcombine -strncmp-inline-threshold=0 < %s | FileCheck --check-prefixes=CHECK,TH-0 %s
+
+declare i32 @strcmp(ptr nocapture, ptr nocapture)
+declare i32 @strncmp(ptr nocapture, ptr nocapture, i64)
+
+ at s1 = constant [1 x i8] c"\00", align 1
+ at s2n = constant [2 x i8] c"aa", align 1
+ at s3 = constant [3 x i8] c"aa\00", align 1
+ at s4 = constant [4 x i8] c"aab\00", align 1
+
+; strncmp(s, "aa", 1)
+define i1 @test_strncmp_0(i8* %s) {
----------------
FLZ101 wrote:

done.

https://github.com/llvm/llvm-project/pull/89371


More information about the llvm-commits mailing list