-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AggressiveInstCombine] Add tests for memchr inline threshold #121711
base: main
Are you sure you want to change the base?
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-transforms Author: None (natedal) Changes(This adds a test checking that, if length=2, memchr is called. This is undesirable as it would be faster to directly compare the two array elements with the target element, rather than calling the external memchr function.) Full diff: https://github.com/llvm/llvm-project/pull/121711.diff 1 Files Affected:
diff --git a/llvm/test/Transforms/AggressiveInstCombine/memchr.ll b/llvm/test/Transforms/AggressiveInstCombine/memchr.ll
index 2601b9f05a97f9..1f1938eecafe69 100644
--- a/llvm/test/Transforms/AggressiveInstCombine/memchr.ll
+++ b/llvm/test/Transforms/AggressiveInstCombine/memchr.ll
@@ -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:
+; CHECK-NEXT: [[MEMCHR:%.*]] = call ptr @memchr(ptr @str, i32 [[X]], i64 [[LEN]])
+; CHECK-NEXT: ret ptr [[MEMCHR]]
+;
+entry:
+ %memchr = call ptr @memchr(ptr @str, i32 %x, i64 %len)
+ ret ptr %memchr
+}
|
; 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ~~
>>>>>>
--
(This adds a test checking that, if length=2, memchr is called. This is undesirable as it would be faster to directly compare the two array elements with the target element, rather than calling the external memchr function.)