From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jamie Lokier To: gcc@gcc.gnu.org, Linus Torvalds Cc: Andrew Morton , Alan Cox , lkml Subject: GCC still keeps empty loops? (was: [patch 4/21] fix ARCH_HAS_PREFETCH) Date: Sun, 11 Aug 2002 13:07:00 -0000 Message-id: <20020811210718.B3206@kushida.apsleyroad.org> References: <3D56B13A.D3F741D1@zip.com.au> X-SW-Source: 2002-08/msg00637.html Linus Torvalds wrote: > I thought that special case was removed long ago, because it is untenable > in C++ etc (where such empty loops happen due to various abstraction > issues, and not optimizing them away is just silly). > > But testing shows that you're right at least for 2.95 and 2.96. Argh Unbelievably, 3.1 doesn't remove empty loops either. I think there's a case for a compiler flag, `-fremove-empty-loops'. Empty loop delays aren't portable acrosss compilers in general. If you _really_ want an empty loop that must always work with GCC, it's easy enough to write: for (i = 0; i < 100000; i++) __asm__ __volatile__ (""); -- Jamie