[PATCH] D113872: [CGP] Handle select instructions relying on the same condition

Sotiris Apostolakis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 23 16:55:40 PST 2021


apostolakis added a comment.

I am actually in the process of porting some of the ideas of `X86CmovConversion.cpp` in CGP. Mainly the idea of doing a loop-based critical path analysis, and potentially make this x86-specific pass obsolete. 
In general, it is quite tricky to get this conversion right and changes can easily lead to regressions. Even with the existing shallow and conservative heuristics in CGP (that rarely convert selects), I find several cases where CGP harms performance by converting a select to a branch. So, I am reconsidering every heuristic.
`X86CmovConversion.cpp` is towards the right direction but it cannot leverage profile information which are available in CGP. It also aggressively converts conditional moves with load operands which is often not ideal. 
IfConversion passes do not currently convert branches for all architectures (AFAIK not for x86 and AArch64, not sure about PowerPC).

By the way, in CGP you can get an architecture-specific misprediction penalty (you can get a `TargetSchedModel` using the `TargetSubtargetInfo` field of `CodeGenPrepare`). Note though that without any PMU, the compiler cannot really guess the misprediction rate. Therefore, the actual cost of misspeculation is not really computable. In `X86CmovConversion.cpp`, the misprediction rate is conservatively assumed to be 25%. 
That said, a target-specific pass would give you access to other forms of information; for example one could better model the backend pressure caused by the lengthy dependence chains of predicated code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113872/new/

https://reviews.llvm.org/D113872



More information about the llvm-commits mailing list