https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82803
--- Comment #3 from Alex Mohr <amohr at amohr dot org> --- FWIW a loop is not required. This generates 4 calls to __tls_get_addr: static thread_local int x; int g(); int f() { int *px = &x; if (g()) *px += g(); if (g()) *px += g(); if (g()) *px += g(); return *px; }