Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754440AbbK0JZI (ORCPT ); Fri, 27 Nov 2015 04:25:08 -0500 Received: from mail-yk0-f172.google.com ([209.85.160.172]:33568 "EHLO mail-yk0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754042AbbK0JZD (ORCPT ); Fri, 27 Nov 2015 04:25:03 -0500 MIME-Version: 1.0 In-Reply-To: <7B39C9C2-1093-49CE-9A1E-5059A57C298A@gmail.com> References: <87si3rbz6p.fsf@rasmusvillemoes.dk> <7B39C9C2-1093-49CE-9A1E-5059A57C298A@gmail.com> Date: Fri, 27 Nov 2015 11:25:02 +0200 Message-ID: Subject: Re: no-op delay loops From: Andy Shevchenko To: yalin wang Cc: Rasmus Villemoes , Ralf Baechle , linux-mips@linux-mips.org, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1176 Lines: 36 On Fri, Nov 27, 2015 at 11:04 AM, yalin wang wrote: >> On Nov 27, 2015, at 16:53, 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? >> > you can try to declare i as volatile int i; > may gcc will not optimize it . Might be, but Rasmus as I can see asked about *existing* code. -- With Best Regards, Andy Shevchenko -- 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/