-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[flang-rt] Simplify INDEX with len-1 SUBSTRING. #137889
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
Conversation
The len-1 case is noticeably slower than gfortran's straightforward implementation https://github.com/gcc-mirror/gcc/blob/075611b646e5554ae02b2622061ea1614bf16ead/libgfortran/intrinsics/string_intrinsics_inc.c#L253 This change speeds up a simple microkernel by 37% on icelake.
flang-rt/lib/runtime/character.cpp
Outdated
if (wantLen == 1) { | ||
// Trivial case for single character lookup. | ||
// We can use simple forward search. | ||
CHAR ch = want[0]; |
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.
This could just become a call to std::memchr()
for KIND==1.
For other kinds, please add braced initialization to the two declarations here.
flang-rt/lib/runtime/character.cpp
Outdated
// We can use simple forward search. | ||
CHAR ch{want[0]}; | ||
if constexpr (std::is_same_v<CHAR, char>) { | ||
auto pos{reinterpret_cast<const CHAR *>( |
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.
Save a line with if (auto pos{}) { ...
The len-1 case is noticeably slower than gfortran's straightforward implementation https://github.com/gcc-mirror/gcc/blob/075611b646e5554ae02b2622061ea1614bf16ead/libgfortran/intrinsics/string_intrinsics_inc.c#L253 This change speeds up a simple microkernel by 37% on icelake.
The len-1 case is noticeably slower than gfortran's straightforward implementation https://github.com/gcc-mirror/gcc/blob/075611b646e5554ae02b2622061ea1614bf16ead/libgfortran/intrinsics/string_intrinsics_inc.c#L253 This change speeds up a simple microkernel by 37% on icelake.
The len-1 case is noticeably slower than gfortran's straightforward implementation https://github.com/gcc-mirror/gcc/blob/075611b646e5554ae02b2622061ea1614bf16ead/libgfortran/intrinsics/string_intrinsics_inc.c#L253 This change speeds up a simple microkernel by 37% on icelake.
The len-1 case is noticeably slower than gfortran's straightforward implementation https://github.com/gcc-mirror/gcc/blob/075611b646e5554ae02b2622061ea1614bf16ead/libgfortran/intrinsics/string_intrinsics_inc.c#L253 This change speeds up a simple microkernel by 37% on icelake.
The len-1 case is noticeably slower than gfortran's straightforward
implementation https://github.com/gcc-mirror/gcc/blob/075611b646e5554ae02b2622061ea1614bf16ead/libgfortran/intrinsics/string_intrinsics_inc.c#L253
This change speeds up a simple microkernel by 37% on icelake.