[PATCH] D157581: [SelectionDAG][X86][WIP] Don't always seperate conditions in `(br (and/or cond0, cond1))` into seperate branches

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 21:03:24 PDT 2023


goldstein.w.n created this revision.
goldstein.w.n added reviewers: pengfei, RKSimon.
Herald added a subscriber: hiraditya.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

It makes sense to split if the cost of computing `cond1` is high
(proportionally to how likely `cond0` is), but it doesn't really make
sense to introduce a second branch if its only a few instructions.

Splitting can also get in the way of potentially folding patterns.

This patch introduces some logic to try to check if the cost of
computing `cond1` is relatively low, and if so don't split the
branches.

Note: The cost-model aspect of this patch is entirely not
benchmarked. This is a WIP and at the very least needs tuning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157581

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/test/CodeGen/X86/2006-04-27-ISelFoldingBug.ll
  llvm/test/CodeGen/X86/2007-08-09-IllegalX86-64Asm.ll
  llvm/test/CodeGen/X86/2007-12-18-LoadCSEBug.ll
  llvm/test/CodeGen/X86/2008-02-18-TailMergingBug.ll
  llvm/test/CodeGen/X86/2008-04-17-CoalescerBug.ll
  llvm/test/CodeGen/X86/avx-cmp.ll
  llvm/test/CodeGen/X86/block-placement.ll
  llvm/test/CodeGen/X86/cmp.ll
  llvm/test/CodeGen/X86/dagcombine-and-setcc.ll
  llvm/test/CodeGen/X86/div-rem-pair-recomposition-unsigned.ll
  llvm/test/CodeGen/X86/or-branch.ll
  llvm/test/CodeGen/X86/peephole-na-phys-copy-folding.ll
  llvm/test/CodeGen/X86/pr33747.ll
  llvm/test/CodeGen/X86/pr37025.ll
  llvm/test/CodeGen/X86/pr38795.ll
  llvm/test/CodeGen/X86/setcc-logic.ll
  llvm/test/CodeGen/X86/swifterror.ll
  llvm/test/CodeGen/X86/tail-dup-merge-loop-headers.ll
  llvm/test/CodeGen/X86/tail-opts.ll
  llvm/test/CodeGen/X86/tailcall-extract.ll
  llvm/test/CodeGen/X86/test-shrink-bug.ll
  llvm/test/CodeGen/X86/x86-shrink-wrap-unwind.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157581.548872.patch
Type: text/x-patch
Size: 166257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230810/5f5c7c7f/attachment.bin>


More information about the llvm-commits mailing list