Hi,
When loop is rotated, the exit branch becomes a normal branch go to or skip the rotated loop. Since it's duplicated from loop exit branch, the result branch should have the same BPI as loop exit branch. However, the branch after rotation has nothing to do with the original loop and would very likely be predicated as 50/50% probability in BPI. This patch adds branch_weights metadata for it so it can be predicted with the same probability as loop exit branch. I also updated and looked into related tests and can confirm the change is expected.
Note that I searched around the code base but didn't see many use of branch_weight metadata, I assume it's mostly for use of profiled probability? So maybe it's inappropriate to use branch_weights metadata in this case, unfortunately, I didn't come up with any other better idea. Much appreciated for any comments that if I should handle the issue differently.
Thanks,
bin
clang-format: please reformat the code