Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754526AbbK0LoP (ORCPT ); Fri, 27 Nov 2015 06:44:15 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:54822 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753982AbbK0LoN (ORCPT ); Fri, 27 Nov 2015 06:44:13 -0500 Date: Fri, 27 Nov 2015 12:20:26 +0100 From: Ralf Baechle To: Rasmus Villemoes Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org Subject: Re: no-op delay loops Message-ID: <20151127112025.GD20269@linux-mips.org> References: <87si3rbz6p.fsf@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87si3rbz6p.fsf@rasmusvillemoes.dk> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1260 Lines: 37 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/