[cfe-dev] One little test, comparing clang and gcc

David Chisnall theraven at sucs.org
Fri Oct 30 05:41:51 PDT 2009


On 30 Oct 2009, at 12:14, Sebastian Redl wrote:

> Don't we intentionally *not* optimize out because it's a classical
> delay-loop?


That should probably be a target-specific decision.  On a multitasking  
operating system, you want to optimise these away, because you don't  
get a deterministic delay anyway (so running it or not running it does  
not alter the language model) and if you want a short wait then you  
should call something like sleep(0) or sched_yield().  On something  
like a PIC16 target with no OS, this code was probably intended as a  
delay loop.

In the original example, it's actually slightly more subtle; the  
original code had some things in the loop, but they were optimised  
away during macro expansion (op) and unused variable elimination (fi =  
(float) i).  In this case, removing the loop always makes sense.

David

-- Sent from my brain




More information about the cfe-dev mailing list