From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Not good for Ada endorsement Date: Fri, 9 Jul 2021 11:21:02 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <5a1cegtfm5ibqej3ldebpc4g99ujniqt9u@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 9 Jul 2021 09:21:03 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="7dfc9170bc246080afb1a33abe93bee2"; logging-data="2938"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/W4CN/GhyB8JbWrryYMzW+U6DIMS0xnSc=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 Cancel-Lock: sha1:6oM+xjxAn6assJmYpFzLWfU4hLc= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:62366 List-Id: On 7/9/21 11:16 AM, Jeffrey R. Carter wrote: > On 7/9/21 10:33 AM, Egil H H wrote: >> >> On my computer, at least, GNAT is not happy about incrementing Number by 2 >> in the inner loop. I get a bit better performance by modifying the check to >> >>        if Number mod 2 /= 0 and then Sieve.Bits(Index_Type(Number)) then >> >> and then incrementing Number by 1. > > Since both operands are positive, mod and rem give the same results, and rem is > usually a bit faster. It's normally not an issue, but in this case it's done > billions of times, so it might make a difference. Note also that short-circuit forms (and then) require disabling processor-level optimizations and may have a negative effect on execution time when used unnecessarily. -- Jeff Carter "Oh Lord, bless this thy hand grenade, that with it thou mayst blow thine enemies to tiny bits, in thy mercy." Monty Python and the Holy Grail 24