https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111011

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
There's nothing wrong, we unroll the loop.

> ./cc1 -quiet t.c -O3 -fopt-info
t.c:5:15: optimized: loop unrolled 1 times

adding "# foo" to the asm text you'll see

.L2:
#APP
# 6 "t.c" 1
        # foo
# 0 "" 2
# 6 "t.c" 1
        # foo
# 0 "" 2
#NO_APP
        subq    $2, %rax
        jne     .L2

there's no data dependence with 'count' for the asm.  You can instead use

#include <stdint.h>

int main() {
  int64_t count=27000000000;
  while (count>0) {
    __asm__ __volatile__("" : "=g" (count) : "0" (count) : "memory");
    --count;
  }
  return 0;
}

to get the desired effect.

Reply via email to