From: Paul Eggert <eggert@cs.ucla.edu>
To: "Pádraig Brady" <P@draigBrady.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH] strftime: support %q to output the quarter of year
Date: Fri, 04 Nov 2016 04:12:00 -0000 [thread overview]
Message-ID: <e87d09dd-2c1a-c03b-e967-f8b0f246bfb9@cs.ucla.edu> (raw)
In-Reply-To: <c16c3a8b-857a-5109-6500-4cfebd86606d@draigBrady.com>
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?
next prev parent reply other threads:[~2016-11-04 4:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-03 19:46 Pádraig Brady
2016-11-03 19:58 ` Florian Weimer
2016-11-03 20:28 ` Adhemerval Zanella
2016-11-03 22:00 ` Joseph Myers
2016-11-04 1:47 ` Pádraig Brady
2016-11-04 4:12 ` Paul Eggert [this message]
2016-11-04 11:33 ` Rafal Luzynski
2016-11-04 14:27 ` [PATCH v3] strftime,strptime: have %q represent " Pádraig Brady
2016-11-04 11:41 ` [PATCH] strftime: support %q to output " Szabolcs Nagy
2016-11-04 12:00 ` Pádraig Brady
2016-11-04 12:08 ` Szabolcs Nagy
2016-11-04 12:23 ` Pádraig Brady
2016-11-04 12:41 ` Szabolcs Nagy
2016-11-04 12:58 ` Pádraig Brady
2016-11-04 13:12 ` keld
2016-11-04 14:12 ` Szabolcs Nagy
2016-11-04 14:57 ` Adhemerval Zanella
2016-11-05 7:19 ` keld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e87d09dd-2c1a-c03b-e967-f8b0f246bfb9@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=P@draigBrady.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).