This patch modifies the conditional compares pass so that it keeps the successor probabilities of the head block up-to-date after the conversion. Previously, the successor probabilities were being normalized to a uniform distribution, even though they may have been heavily biased prior to the conversion (e.g., if one of the edges was the back edge of a loop). This loss of information affected passes later in the pipeline.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Target/AArch64/AArch64ConditionalCompares.cpp | ||
---|---|---|
143 ↗ | (On Diff #102199) | Huh, we can use a const instance of this to change the probabilities... Looking at MachineBranchProbabilityInfo I wonder why this was implemented as a pass and not just a set of utility functions. Anyway just wanted to write this down, it isn't really relevant for the review at hand. |
590 ↗ | (On Diff #102199) | I cannot convince myself right now that it is always succ_begin() that points to Tail. Wouldn't we need to search for the right successor? |
Thanks for the comments Matthias! Responses are inline.
lib/Target/AArch64/AArch64ConditionalCompares.cpp | ||
---|---|---|
143 ↗ | (On Diff #102199) | I agree, this was a bit confusing to me. My understanding is that MachineBranchProbabilityInfo is required for reading off the successor probabilities, but that the setting of the probabilities must be done via MachineBasicBlock. |
590 ↗ | (On Diff #102199) | Head is required to have exactly two successors, CmpBB and Tail (see the beginning part of canConvert). CmpBB is removed as a successor of Head a few lines up (577), so succ_begin() can only point to Tail here. |
LGTM
lib/Target/AArch64/AArch64ConditionalCompares.cpp | ||
---|---|---|
590 ↗ | (On Diff #102199) | Ok, maybe check with an assert() to make life easier for readers? |
Thanks Mathias!
lib/Target/AArch64/AArch64ConditionalCompares.cpp | ||
---|---|---|
590 ↗ | (On Diff #102199) | Will do. |