[llvm] [RISCV] Add TuneJumpIsExpensive (PR #191374)
Pengcheng Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 00:00:18 PDT 2026
wangpc-pp wrote:
> > However, it appears to be applied as a global heuristic. I’m a bit concerned that it may be overly aggressive in some cases, as it moves away from short-circuit behavior—evaluating all conditions before branching, even when an earlier condition could already determine the outcome.
>
> I think the best of both worlds would be that `TargetLoweringInfo::isJumpExpensive` would return an integer for the maximum number of branches to allow, similar to `-riscv-cbc-max-branch` in #191158, and SelectionDAGBuilder/`CodeGenPrepare::splitBranchCondition` would only emit said maximum number.
I think ISel may not be a suitable place to achieve this. These branches are folded into selects in `llvm/lib/Transforms/Utils/SimplifyCFG.cpp:foldBranchToCommonDest`. If we want to tune this behavior, we should do it earlier in `SimplifyCFG` instead of turning them back to branches in later stages like ISel or MIR passes.
https://github.com/llvm/llvm-project/pull/191374
More information about the llvm-commits
mailing list