On Mon, 15 May 2023 10:04:22 GMT, Chang Peng <d...@openjdk.org> wrote:
> > This looks like it might be removed by loop opts. I think you might need a > > blackhole somewhere. > > `m` will be updated in every iteration of this loop, so `m` is not a > loop-invariants actually. I can see the assembly code of this loop by using > JMH perfasm. Isn't it? Looks to me like all it does is flip `m` each time. Whether or not this code is optimized today isn't relevant. So it's the same as for (int i = 0; i < LENGTH/2; i++) { res += m.trueCount(); } m = m.not(); for (int i = 0; i < LENGTH/2; i++) { res += m.trueCount(); } ... which is trivially optimizable, no? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13974#discussion_r1193674595