[llvm] b0924ed - [AggressiveInstCombine] Add tests for memchr inline threshold (NFC) (#121711)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 28 22:06:08 PST 2025
Author: natedal
Date: 2025-01-29T14:06:04+08:00
New Revision: b0924ed64e0d814ab23fa474c2047030dd3a2f46
URL: https://github.com/llvm/llvm-project/commit/b0924ed64e0d814ab23fa474c2047030dd3a2f46
DIFF: https://github.com/llvm/llvm-project/commit/b0924ed64e0d814ab23fa474c2047030dd3a2f46.diff
LOG: [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.
Added:
Modified:
llvm/test/Transforms/AggressiveInstCombine/memchr.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/AggressiveInstCombine/memchr.ll b/llvm/test/Transforms/AggressiveInstCombine/memchr.ll
index 2601b9f05a97f9..b26320be634b85 100644
--- a/llvm/test/Transforms/AggressiveInstCombine/memchr.ll
+++ b/llvm/test/Transforms/AggressiveInstCombine/memchr.ll
@@ -161,3 +161,16 @@ entry:
%memchr = call ptr @memchr(ptr @str_long, i32 %x, i64 8)
ret ptr %memchr
}
+
+; We want to check that the compiler still calls memchr if the length is non-constant:
+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: [[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
+}
More information about the llvm-commits
mailing list