This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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] |
Pádraig Brady wrote:
+ DO_NUMBER (1, tp->tm_mon / 3 + 1);
I couldn't resist puzzling this one out. We can assume 0 <= tp->tm_mon < 12, so this should be a tad more efficient:
DO_NUMBER (1, ((tp->tm_mon * 11) >> 5) + 1);With gcc 6.2.0 -O2 x86-64, the former uses imull with 6 insns, the latter just leal with 4 insns. Perhaps GCC should be smart enough to figure this out on its own, but what would be the fun of that?
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |