[BOLT] Avoid pointless loop rotation
authorspupyrev <spupyrev@fb.com>
Thu, 17 Mar 2022 16:51:07 +0000 (09:51 -0700)
committerspupyrev <spupyrev@fb.com>
Tue, 22 Mar 2022 19:42:42 +0000 (12:42 -0700)
commit4609f60ebc57d0bd63f97cae11978b96c53204d6
tree4ba1c90cb6e2893f8b3296bb036a209267fe2b24
parent03949165cd55958350f3494c92aebfa255086819
[BOLT] Avoid pointless loop rotation

It seems the earlier implementation does not follow the description
in LoopRotationPass.h: It rotates loops even if they are already laid out
correctly. The diff adjusts the behaviour.

Given that the impact of LoopInversionPass is minor, this change won't
yield significant perf differences. Tested on clang-10: there seems to be a
0.1%-0.3% cpu win and a small reduction of branch misses.

**Before:**
BOLT-INFO: 120 Functions were reordered by LoopInversionPass

**After:**
BOLT-INFO: 79 Functions were reordered by LoopInversionPass

Reviewed By: yota9

Differential Revision: https://reviews.llvm.org/D121921
bolt/lib/Passes/LoopInversionPass.cpp
bolt/test/X86/loop-inversion-pass.s