[Bug tree-optimization/81739] New: Replace calls to memcmp with more efficient code if possible
bugzilla@poradnik-webmastera.com
gcc-bugzilla@gcc.gnu.org
Sun Aug 6 09:05:00 GMT 2017
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);
}
More information about the Gcc-bugs
mailing list