This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/2] strncmp builtin expansion improvement


On 11/01/2016 04:29 PM, Aaron Sawdey wrote:
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?
So what's the motivation here? When we don't have any constants then I'd think we'd be better off punting into the library.

Jeff



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]