[PATCH] D39262: [CodeGen] Peel off the dominant case in switch statement in lowering

Rong Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 16:03:36 PDT 2017


xur created this revision.

This patch peels off the top case in switch statement into a branch if the probability exceeds a threshold.
This will help the branch prediction and avoids the extra compares when lowering into chain of branches.
A previous patch of the same idea was on CFG simplification pass:
https://reviews.llvm.org/D37940
This patch is implemented in SelectionDAG.


https://reviews.llvm.org/D39262

Files:
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  test/CodeGen/Generic/MachineBranchProb.ll
  test/CodeGen/Generic/switch-lower-peel-top-case.ll
  test/CodeGen/X86/switch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39262.120144.patch
Type: text/x-patch
Size: 9571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171024/5c197860/attachment.bin>


More information about the llvm-commits mailing list