diff options
author | Andrew Pinski <andrew.pinski@oss.qualcomm.com> | 2025-08-28 17:20:21 -0700 |
---|---|---|
committer | Andrew Pinski <andrew.pinski@oss.qualcomm.com> | 2025-08-29 20:13:00 -0700 |
commit | bfa70ddb650ec91c2511d351b2b3c3f78dfad6d4 (patch) | |
tree | 62bcc01c69ee67c1815764bc0da006d168ef01d9 /libjava/classpath | |
parent | 668e607efe52abbe4612fa85454731d26a71a5be (diff) | |
download | gcc-bfa70ddb650ec91c2511d351b2b3c3f78dfad6d4.zip gcc-bfa70ddb650ec91c2511d351b2b3c3f78dfad6d4.tar.gz gcc-bfa70ddb650ec91c2511d351b2b3c3f78dfad6d4.tar.bz2 |
forwprop: Copy the memcmp optimization from strlen to forwprop [PR116651]
To better optimize code dealing with `memcmp == 0` where we have
a small constant size, we can inline the memcmp in those cases.
There is code to do this in strlen but that is run too late in
the case where we can figure out the value of one of the arguments
to memcmp. So this copies the optimization to forwprop.
An example of where this helps is:
```
bool cmpvect(const std::vector<int> &a) { return a == std::vector<int>{10}; }
```
Where the above should be optimized to just `return a.size() == 1 && a[0] == 10;`.
Note pr44130.c testcase needed to change as now it will be optimized away otherwise.
Note the loop in pr44130.c os also vectorized which it was not before.
Note the optimization remains in strlen as the other part (memcmp -> memcmp_eq)
should move to either isel or fab and I didn't want to remove it just yet.
Bootstrapped and tested on x86_64-linux-gnu.
Changes since v1:
* v2: Add verification of arguments to memcmp to simplify_builtin_memcmp.
PR tree-optimization/116651
PR tree-optimization/93265
PR tree-optimization/103647
PR tree-optimization/52171
gcc/ChangeLog:
* tree-ssa-forwprop.cc (simplify_builtin_memcmp): New function.
(simplify_builtin_call): Call simplify_builtin_memcmp for memcmp
memcmp_eq builtins.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr44130.c: Add an inline-asm clobber.
* g++.dg/tree-ssa/vector-compare-1.C: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Diffstat (limited to 'libjava/classpath')
0 files changed, 0 insertions, 0 deletions