From: Ralf Baechle <ralf@linux-mips.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: no-op delay loops
Date: Fri, 27 Nov 2015 12:20:26 +0100 [thread overview]
Message-ID: <20151127112025.GD20269@linux-mips.org> (raw)
In-Reply-To: <87si3rbz6p.fsf@rasmusvillemoes.dk>
On Fri, Nov 27, 2015 at 09:53:50AM +0100, Rasmus Villemoes wrote:
> It seems that gcc happily compiles
>
> for (i = 0; i < 1000000000; ++i) ;
>
> into simply
>
> i = 1000000000;
>
> (which is then usually eliminated as a dead store). At least at -O2, and
> when i is not declared volatile. So it would seem that the loops at
>
> arch/mips/pci/pci-rt2880.c:235
> arch/mips/pmcs-msp71xx/msp_setup.c:80
> arch/mips/sni/reset.c:35
>
> actually don't do anything. (In the middle one, i is 'register', but
> that doesn't change anything.) Is mips compiled with some special flags
> that would make gcc actually emit code for the above?
Thanks for reporting!
GCC used to intentionally not eleminate empty loops. This has changed a
while ago. Using volatile for the loop variable will result in atrocious
code so should be avoided.
One problem of these open coded loops is that it's not obvious how much
delay was actually intended so when fixing this I will have to do a bit
of precission guessing ;-)
Ralf
prev parent reply other threads:[~2015-11-27 11:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 8:53 no-op delay loops Rasmus Villemoes
2015-11-27 9:04 ` yalin wang
2015-11-27 9:25 ` Andy Shevchenko
2015-11-27 11:17 ` Arnd Bergmann
2015-11-30 21:29 ` Rasmus Villemoes
2015-11-30 21:44 ` Arnd Bergmann
2015-12-01 1:25 ` Ralf Baechle
2015-12-01 15:31 ` Richard Henderson
2015-11-27 11:20 ` Ralf Baechle [this message]
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=20151127112025.GD20269@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux@rasmusvillemoes.dk \
/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 NNTP newsgroup(s).