From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15447 invoked by alias); 4 Nov 2016 04:12:31 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 15428 invoked by uid 89); 4 Nov 2016 04:12:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-4.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=p=c3=a1draig?= X-HELO: zimbra.cs.ucla.edu Subject: Re: [PATCH] strftime: support %q to output the quarter of year To: =?UTF-8?Q?P=c3=a1draig_Brady?= , libc-alpha@sourceware.org References: <1478202401-5238-1-git-send-email-P@draigBrady.com> From: Paul Eggert Message-ID: Date: Fri, 04 Nov 2016 04:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-SW-Source: 2016-11/txt/msg00136.txt.bz2 P=C3=A1draig Brady wrote: > + DO_NUMBER (1, tp->tm_mon / 3 + 1); I couldn't resist puzzling this one out. We can assume 0 <=3D tp->tm_mon < = 12, so=20 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 j= ust=20 leal with 4 insns. Perhaps GCC should be smart enough to figure this out on= its=20 own, but what would be the fun of that?