[llvm] [AggressiveInstCombine] Add tests for memchr inline threshold (PR #121711)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 5 23:39:16 PST 2025


================
@@ -161,3 +161,17 @@ entry:
   %memchr = call ptr @memchr(ptr @str_long, i32 %x, i64 8)
   ret ptr %memchr
 }
+
+
+define ptr @test_memchr_non_constant_length2(i32 %x, i64 %len) {
+; CHECK-LABEL: define ptr @test_memchr_non_constant_length2(
+; CHECK-SAME: i32 [[X:%.*]], i64 [[LEN:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT: ; We want to check that the compiler still calls memchr:
----------------
dtcxzyw wrote:

Please move this comment before the header of this function.
```
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-w5ssp-1/llvm-project/github-pull-requests/build/bin/opt -S -passes=aggressive-instcombine --memchr-inline-threshold=5 < /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-w5ssp-1/llvm-project/github-pull-requests/llvm/test/Transforms/AggressiveInstCombine/memchr.ll | /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-w5ssp-1/llvm-project/github-pull-requests/build/bin/FileCheck /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-w5ssp-1/llvm-project/github-pull-requests/llvm/test/Transforms/AggressiveInstCombine/memchr.ll
+ /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-w5ssp-1/llvm-project/github-pull-requests/build/bin/opt -S -passes=aggressive-instcombine --memchr-inline-threshold=5
+ /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-w5ssp-1/llvm-project/github-pull-requests/build/bin/FileCheck /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-w5ssp-1/llvm-project/github-pull-requests/llvm/test/Transforms/AggressiveInstCombine/memchr.ll
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-w5ssp-1/llvm-project/github-pull-requests/llvm/test/Transforms/AggressiveInstCombine/memchr.ll:170:15: error: CHECK-NEXT: expected string not found in input
; CHECK-NEXT: ; We want to check that the compiler still calls memchr:
              ^
<stdin>:133:7: note: scanning from here
entry:
      ^
<stdin>:134:8: note: possible intended match here
 %memchr = call ptr @memchr(ptr @str, i32 %x, i64 %len)
       ^

Input file: <stdin>
Check file: /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-w5ssp-1/llvm-project/github-pull-requests/llvm/test/Transforms/AggressiveInstCombine/memchr.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
          128:  %memchr = call ptr @memchr(ptr @str_long, i32 %x, i64 8) 
          129:  ret ptr %memchr 
          130: } 
          131:  
          132: define ptr @test_memchr_non_constant_length2(i32 %x, i64 %len) { 
          133: entry: 
next:170'0           X error: no match found
          134:  %memchr = call ptr @memchr(ptr @str, i32 %x, i64 %len) 
next:170'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:170'1            ?                                                 possible intended match
          135:  ret ptr %memchr 
next:170'0     ~~~~~~~~~~~~~~~~~
          136: } 
next:170'0     ~~
>>>>>>

--
```

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


More information about the llvm-commits mailing list