This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81739] New: Replace calls to memcmp with more efficient code if possible
- From: "bugzilla at poradnik-webmastera dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 06 Aug 2017 09:04:43 +0000
- Subject: [Bug tree-optimization/81739] New: Replace calls to memcmp with more efficient code if possible
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81739
Bug ID: 81739
Summary: Replace calls to memcmp with more efficient code if
possible
Product: gcc
Version: 4.8.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: bugzilla@poradnik-webmastera.com
Target Milestone: ---
In our app we had function which was comparing two uint64 values using memcmp.
As it turned out, it was taking a lot of time. After some googling we found
this link:
https://stackoverflow.com/questions/10996418/efficient-integer-compare-function
After fixing our code using this approach it started working much faster.
Please implement such optimization in gcc itself. I found that it already
optimizes some calls to memcpy, it could do the same with memcmp too.
Code:
#include <string.h>
#include <stdint.h>
int cmp1(uint64_t a, uint64_t b)
{
return memcmp(&a, &b, sizeof(uint64_t));
}
int cmp2(uint64_t a, uint64_t b)
{
return a < b ? -1 : (a > b);
}