If the branch isn't unpredictable, and it is predicted to *not* branch
to the block we are considering speculatively executing,
then it seems counter-productive to execute the code that is predicted not to be executed.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
2380–2384 | I think it would be easier to read without the potential double complement: if (BI->extractProfMetadata(TWeight, FWeight) && (TWeight + FWeight) != 0) { uint64_t EndWeight = Invert ? TWeight : FWeight; BranchProbability BIEndProb = BranchProbability::getBranchProbability(EndWeight, TWeight + FWeight); (although the meaning of Invert seems reversed from the code example in the function comment at line 2331) | |
llvm/test/Transforms/SimplifyCFG/speculatively-execute-block-profmd.ll | ||
254 | Add one more negative test to verify that we are respecting the TTI setting? It would need a different metadata - { 98, 2 } or similar. |
Thank you for the review!
Please note that D106717 is another similar patch.
I do hope to merge these two functions, but later.
A bit of necro-posting, but i was looking at this code again, and i'm wondering,
if the profile says that the only block that we are about to speculate
is predictably taken, does it actually make sense to speculate it,
incurring the cost of the select?
I think it would be easier to read without the potential double complement:
(although the meaning of Invert seems reversed from the code example in the function comment at line 2331)