This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Update successor probabilities after ccmp-conversion
ClosedPublic

Authored by mssimpso on Jun 12 2017, 10:32 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

mssimpso created this revision.Jun 12 2017, 10:32 AM
MatzeB added inline comments.Jun 19 2017, 11:17 AM
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.

MatzeB accepted this revision.Jun 26 2017, 10:44 AM

LGTM

lib/Target/AArch64/AArch64ConditionalCompares.cpp
590 ↗(On Diff #102199)

Ok, maybe check with an assert() to make life easier for readers?

This revision is now accepted and ready to land.Jun 26 2017, 10:44 AM

Thanks Mathias!

lib/Target/AArch64/AArch64ConditionalCompares.cpp
590 ↗(On Diff #102199)

Will do.

This revision was automatically updated to reflect the committed changes.