[cfe-dev] No loop optimisation?

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Fri Nov 6 04:24:33 PST 2015


On Fri, Nov 06, 2015 at 10:32:50AM +0000, mats petersson via cfe-dev wrote:
> I saw a question on "why does clang do this" on Stack Overflow, and boiling
> it down to simple code, the following is the code:
> 
>      size_t ret;
>      for(int i = 0; i < LOOP_COUNT; i++)
>         ret = sizeof("abcd");
> 
> Which I would expect to be optimsied into:
> 
>     size_t ret = 5;
> 
> and the loop disappear.

Works fine here. How exactly did you compile it and which version of
clang are you using?

Joerg



More information about the cfe-dev mailing list