This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/52171] memcmp/strcmp/strncmp can be optimized when the result is tested for [in]equality with 0
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 08 Feb 2012 13:05:23 +0000
- Subject: [Bug tree-optimization/52171] memcmp/strcmp/strncmp can be optimized when the result is tested for [in]equality with 0
- Auto-submitted: auto-generated
- References: <bug-52171-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52171
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2012-02-08
AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org
|gnu.org |
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-08 13:05:23 UTC ---
Created attachment 26610
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26610
prototype for memcmp
Patch that handles
int cmp (char *p, char *q)
{
char *pa = __builtin_assume_aligned (p, 4);
char *qa = __builtin_assume_aligned (q, 4);
if (__builtin_memcmp (pa, qa, 4) != 0)
return 1;
return 0;
}
from forwprops simplify_builtin_call.
Possibly we could consider vector modes / compares (for greater size) and
allow misaligned accesses on !STRICT_ALIGNMENT targets. We can also
handle non-power-of-two sizes by using (A ^ B) & mask, but we have to
think about endianess there.