[all-commits] [llvm/llvm-project] dfacb8: [NFC][InstCombine] Add some readability by using `...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Fri Dec 16 18:19:59 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dfacb8d211c859f098f2f84a3c08b6aef54212fd
      https://github.com/llvm/llvm-project/commit/dfacb8d211c859f098f2f84a3c08b6aef54212fd
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2022-12-17 (Sat, 17 Dec 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

  Log Message:
  -----------
  [NFC][InstCombine] Add some readability by using `DecomposedSelect` struct


  Commit: dcabd3f01ab046670898369ddaf68a72aa767d3f
      https://github.com/llvm/llvm-project/commit/dcabd3f01ab046670898369ddaf68a72aa767d3f
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2022-12-17 (Sat, 17 Dec 2022)

  Changed paths:
    M llvm/test/Transforms/InstCombine/D139275_c4001580.ll

  Log Message:
  -----------
  [NFC][InstCombine] Simplify miscompile testcase


  Commit: 07ecdd9b1a8af51f07d5f4dfe46845c801482a39
      https://github.com/llvm/llvm-project/commit/07ecdd9b1a8af51f07d5f4dfe46845c801482a39
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2022-12-17 (Sat, 17 Dec 2022)

  Changed paths:
    M llvm/include/llvm/IR/PatternMatch.h
    M llvm/test/Transforms/InstCombine/D139275_c4001580.ll
    M llvm/unittests/IR/PatternMatch.cpp

  Log Message:
  -----------
  [IR][PatternMatch] `m_Not`: do not apply inner matcher unless `Not` matched

This is consistent with how other commutative matchers operate,
and i assumed that is how this one worked, alas it did not,
and thus `foldNestedSelects()` was miscompiling stuff.


  Commit: 428f36401b1b695fd501ebfdc8773bed8ced8d4e
      https://github.com/llvm/llvm-project/commit/428f36401b1b695fd501ebfdc8773bed8ced8d4e
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2022-12-17 (Sat, 17 Dec 2022)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/CodeGen/AArch64/rm_redundant_cmp.ll
    M llvm/test/CodeGen/AArch64/tailmerging_in_mbp.ll
    M llvm/test/CodeGen/AArch64/typepromotion-cost.ll
    M llvm/test/CodeGen/PowerPC/ppc-ctr-dead-code.ll
    M llvm/test/CodeGen/PowerPC/pr48527.ll
    M llvm/test/CodeGen/X86/loop-search.ll
    M llvm/test/Transforms/InstCombine/unused-nonnull.ll
    M llvm/test/Transforms/LICM/hoist-phi.ll
    M llvm/test/Transforms/LICM/sinking.ll
    M llvm/test/Transforms/LoopStrengthReduce/AArch64/small-constant.ll
    M llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
    M llvm/test/Transforms/LoopUnroll/scevunroll.ll
    M llvm/test/Transforms/LoopUnroll/unroll-after-peel.ll
    M llvm/test/Transforms/LoopUnroll/unroll-header-exiting-with-phis-multiple-exiting-blocks.ll
    M llvm/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll
    M llvm/test/Transforms/SimplifyCFG/X86/SpeculativeExec.ll
    M llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
    M llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest-phis.ll
    M llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
    M llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll
    M llvm/test/Transforms/SimplifyCFG/switch-on-const-select.ll

  Log Message:
  -----------
  Reland "[SimplifyCFG] `FoldBranchToCommonDest()`: deal with mismatched IV's in PHI's in common successor block"

This reverts commit 37b8f09a4b61bf9bf9d0b9017d790c8b82be2e17,
and returns commit 1bd0b82e508d049efdb07f4f8a342f35818df341.
The miscompile was in InstCombine, and it has been addressed.

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

Differential Revision: https://reviews.llvm.org/D139275


Compare: https://github.com/llvm/llvm-project/compare/12ec5b20c2c1...428f36401b1b


More information about the All-commits mailing list