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]

[PATCH 0/2] strncmp builtin expansion improvement


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


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