diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-06-17 07:33:06 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-07-14 14:10:17 -0700 |
commit | c6cf555a88f8ffb8ec85c2b94fe656ab217260ea (patch) | |
tree | fac88fef4d594a13125d3f361569adae0c57446a /libcpp/include | |
parent | 748f8a8b145dde59c7b63aa68b5a59515b7efc49 (diff) | |
download | gcc-c6cf555a88f8ffb8ec85c2b94fe656ab217260ea.zip gcc-c6cf555a88f8ffb8ec85c2b94fe656ab217260ea.tar.gz gcc-c6cf555a88f8ffb8ec85c2b94fe656ab217260ea.tar.bz2 |
Simplify memchr with small constant strings
When memchr is applied on a constant string of no more than the bytes of
a word, simplify memchr by checking each byte in the constant string.
int f (int a)
{
return __builtin_memchr ("AE", a, 2) != 0;
}
is simplified to
int f (int a)
{
return ((char) a == 'A' || (char) a == 'E') != 0;
}
gcc/
PR tree-optimization/103798
* tree-ssa-forwprop.cc: Include "tree-ssa-strlen.h".
(simplify_builtin_call): Inline memchr with constant strings of
no more than the bytes of a word.
* tree-ssa-strlen.cc (use_in_zero_equality): Make it global.
* tree-ssa-strlen.h (use_in_zero_equality): New.
gcc/testsuite/
PR tree-optimization/103798
* c-c++-common/pr103798-1.c: New test.
* c-c++-common/pr103798-2.c: Likewise.
* c-c++-common/pr103798-3.c: Likewise.
* c-c++-common/pr103798-4.c: Likewise.
* c-c++-common/pr103798-5.c: Likewise.
* c-c++-common/pr103798-6.c: Likewise.
* c-c++-common/pr103798-7.c: Likewise.
* c-c++-common/pr103798-8.c: Likewise.
* c-c++-common/pr103798-9.c: Likewise.
* c-c++-common/pr103798-10.c: Likewise.
Diffstat (limited to 'libcpp/include')
0 files changed, 0 insertions, 0 deletions