Missing loop optimization?

LLVM will optimize out the following loop (effectively replace with if (x < 100) a[x] = 0;):

#include <cstddef>
int a[100];
size_t x;

void f()
{
   for (size_t i = 0; i < 100; ++i)
     if (i == x) {
        a[i] = 0;
        break;
     }
}

But if I comment out the break, it will not remove the loop. Why?

gcc also doesn’t optimize this. Since both compilers are not optimizing, I wonder if I am missing something here.