Skip to content

Commit b0924ed

Browse files
authored
[AggressiveInstCombine] Add tests for memchr inline threshold (NFC) (#121711)
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.
1 parent d4159e2 commit b0924ed

File tree

1 file changed

+13
-0
lines changed
  • llvm/test/Transforms/AggressiveInstCombine

1 file changed

+13
-0
lines changed

llvm/test/Transforms/AggressiveInstCombine/memchr.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,16 @@ entry:
161161
%memchr = call ptr @memchr(ptr @str_long, i32 %x, i64 8)
162162
ret ptr %memchr
163163
}
164+
165+
; We want to check that the compiler still calls memchr if the length is non-constant:
166+
define ptr @test_memchr_non_constant_length2(i32 %x, i64 %len) {
167+
; CHECK-LABEL: define ptr @test_memchr_non_constant_length2(
168+
; CHECK-SAME: i32 [[X:%.*]], i64 [[LEN:%.*]]) {
169+
; CHECK-NEXT: [[ENTRY:.*:]]
170+
; CHECK-NEXT: [[MEMCHR:%.*]] = call ptr @memchr(ptr @str, i32 [[X]], i64 [[LEN]])
171+
; CHECK-NEXT: ret ptr [[MEMCHR]]
172+
;
173+
entry:
174+
%memchr = call ptr @memchr(ptr @str, i32 %x, i64 %len)
175+
ret ptr %memchr
176+
}

0 commit comments

Comments
 (0)