[PATCH] D139275: [SimplifyCFG] `FoldBranchToCommonDest()`: deal with mismatched IV's in PHI's in common successor block

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 4 10:06:19 PST 2022


lebedev.ri created this revision.
lebedev.ri added reviewers: arsenm, fhahn, spatel, efriedma.
lebedev.ri added a project: LLVM.
Herald added subscribers: asbirlea, zzheng, hiraditya.
Herald added a project: All.
lebedev.ri requested review of this revision.
Herald added a subscriber: wdng.

This tries to approach the problem noted by @arsenm:
terrible codegen for `__builtin_fpclassify()`:
https://godbolt.org/z/388zqdE37

Just because the PHI in the common successor happens to have different
incoming values for these two blocks, doesn't mean we have to give up.
It's quite easy to deal with this, we just need to produce a select:
https://alive2.llvm.org/ce/z/000srb

Now, the cost model for this transform is rather overly strict,
so this will basically never fire. We tally all (over all preds)
the selects needed to the NumBonusInsts


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139275

Files:
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Transforms/InstCombine/unused-nonnull.ll
  llvm/test/Transforms/LICM/hoist-phi.ll
  llvm/test/Transforms/LICM/sinking.ll
  llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
  llvm/test/Transforms/LoopUnroll/scevunroll.ll
  llvm/test/Transforms/LoopUnroll/unroll-after-peel.ll
  llvm/test/Transforms/LoopUnroll/unroll-header-exiting-with-phis-multiple-exiting-blocks.ll
  llvm/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll
  llvm/test/Transforms/SimplifyCFG/X86/SpeculativeExec.ll
  llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
  llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest-phis.ll
  llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
  llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll
  llvm/test/Transforms/SimplifyCFG/switch-on-const-select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139275.479930.patch
Type: text/x-patch
Size: 83105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221204/e8ee4a12/attachment.bin>


More information about the llvm-commits mailing list