This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/77718] [7 Regression] expand_builtin_memcmp swaps args
- From: "acsawdey at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 26 Sep 2016 15:28:27 +0000
- Subject: [Bug middle-end/77718] [7 Regression] expand_builtin_memcmp swaps args
- Auto-submitted: auto-generated
- References: <bug-77718-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77718
--- Comment #3 from acsawdey at gcc dot gnu.org ---
Bernd,
I identified the problem on powerpc64le. I think it may not show up on x86_64
because of differences in how builtin memcmp gets expanded. Normally this is
hidden because if both strings are constant, this gets handled by folding. It
only shows up in the test case because the length given is longer than the
string length, which prevents folding (undefined behavior).
It seems clear to me that it is only legitimate to swap the args in the
result_eq case because otherwise you are changing the sign of the result.