The question the optimizer can’t really answer is: will Random.nextInt() ever return 10? If that’s a 64 bit integer it could be a LOOOOOONG time before 10 ever shows up.
If it were a magic lang item, you could treat the resulting value in a special way. Then, you could create an optimization pass for this situation: if a variable is assigned random in a loop and the loop can only be exited with a certain value, the compiler can coerce the magic rand value to it.
The question the optimizer can’t really answer is: will Random.nextInt() ever return 10? If that’s a 64 bit integer it could be a LOOOOOONG time before 10 ever shows up.
If it were a magic lang item, you could treat the resulting value in a special way. Then, you could create an optimization pass for this situation: if a variable is assigned random in a loop and the loop can only be exited with a certain value, the compiler can coerce the magic rand value to it.
Ah yes the halting problem