How could it ever infer it, given C's compilation model?
The only option is when all TU are given at the same time to the compiler, or when LTO is used (in which case it is actually the linker doing the work).
The only option is when all TU are given at the same time to the compiler
Exactly -- which is the case here. But implementing such a cross cutting implementation would probably be annoying, which is what I wanted to convey with
I think they could concievably assume that the value of modulus won’t be changed in this case, since we’re producing an executable directly, but it’s probably annoying to have an optimization looking so far into the future of the compiler pipeline.
Comments
How could it ever infer it, given C's compilation model?
The only option is when all TU are given at the same time to the compiler, or when LTO is used (in which case it is actually the linker doing the work).
Even then, this won't apply to libraries.
Exactly -- which is the case here. But implementing such a cross cutting implementation would probably be annoying, which is what I wanted to convey with