This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 0/2] strncmp builtin expansion improvement
- From: Aaron Sawdey <acsawdey at linux dot vnet dot ibm dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: kkojima at gcc dot gnu dot org, olegendo at gcc dot gnu dot org, nickc at redhat dot com
- Date: Tue, 01 Nov 2016 17:29:08 -0500
- Subject: [PATCH 0/2] strncmp builtin expansion improvement
- Authentication-results: sourceware.org; auth=none
Builtin expansion of strncmp currently only happens when at least one
of the string arguments is a constant string. I'd like to make it also
attempt expansion of the cmpstrnsi pattern in the case where neither
argument is a constant string, as is already done with cmpstrsi in
expand_builtin_strcmp.
There are two parts to this patch:
1) The i386 pattern for cmpstrnsi uses repz cmpsb which does not test
for the zero byte ending the string. At present this relies on the fact
that expand_builtin_strncmp and expand_builtin_strcmp make sure that
there is one string that is constant and the length passed is no longer
than this string. This keeps it out of the failure case: when the
strings are identical but the length is longer so repz cmpsb continues
comparing past the zero byte and produces incorrect results.
2) The actual change to expand_builtin_strncmp. This attempts expansion
via cmpstrnsi in the case where c_strlen() return null for both
strings.
With these two patches bootstrap passes on x86_64 linux, currently
checking regtest. If clean, ok for trunk?
--
Aaron Sawdey, Ph.D. acsawdey@linux.vnet.ibm.com
050-2/C113 (507) 253-7520 home: 507/263-0782
IBM Linux Technology Center - PPC Toolchain