1. Mar 08, 2021
    • Craig Topper's avatar
      [RISCV] Fold (select_cc (xor X, Y), 0, eq/ne, trueV, falseV) -> (select_cc X,... · fdbd5d32
      Craig Topper authored
      [RISCV] Fold (select_cc (xor X, Y), 0, eq/ne, trueV, falseV) -> (select_cc X, Y, eq/ne, trueV, falseV)
      
      This pattern occurs when lowering for overflow operations
      introduce an xor after select_cc has already been formed.
      
      I had to rework another combine that looked for select_cc of an xor
      with 1. That xor will now get combined away so we just need to
      look for the RHS of the select_cc being 1.
      
      Reviewed By: luismarques
      
      Differential Revision: https://reviews.llvm.org/D98130
      fdbd5d32
    • Juneyoung Lee's avatar
      [InstCombine] use safe transformation by default · d672c811
      Juneyoung Lee authored
      .. since it will be folded into and/or anyway
      d672c811
    • Nikita Popov's avatar
      [CVP] Remove -cvp-dont-add-nowrap-flags option · 2b494f85
      Nikita Popov authored
      This option was originally added to work around a bug in LFTR.
      The bug has long since been fixed.
      2b494f85
    • Nikita Popov's avatar
      [DSE] Remove MemDep-based implementation · 176bbcae
      Nikita Popov authored
      The MemorySSA-based implementation has been enabled without issue
      for a while now, so keeping the old implementation around doesn't
      seem useful anymore. This drops the MemDep-based implementation.
      
      Differential Revision: https://reviews.llvm.org/D97877
      176bbcae
    • Juneyoung Lee's avatar
      [InstCombine] fix another poison-unsafe select transformation · 33590ed4
      Juneyoung Lee authored
      This fixes another unsafe select folding by disabling it if
      EnableUnsafeSelectTransform is set to false.
      
      EnableUnsafeSelectTransform's default value is true, hence it won't
      affect generated code (unless the flag is explicitly set to false).
      33590ed4
    • Juneyoung Lee's avatar
      [SimplifyCFG] Update FoldBranchToCommonDest to be poison-safe · 99108c79
      Juneyoung Lee authored
      This patch makes FoldBranchToCommonDest merge branch conditions into `select i1` rather than `and/or i1` when it is called by SimplifyCFG.
      It is known that merging conditions into and/or is poison-unsafe, and this is towards making things *more* correct by removing possible miscompilations.
      Currently, InstCombine simply consumes these selects into and/or of i1 (which is also unsafe), so the visible effect would be very small. The unsafe select -> and/or transformation will be removed in the future.
      There has been efforts for updating optimizations to support the select form as well, and they are linked to D93065.
      
      The safe transformation is fired when it is called by SimplifyCFG only. This is done by setting the new `PoisonSafe` argument as true.
      Another place that calls FoldBranchToCommonDest is LoopSimplify. `PoisonSafe` flag is set to false in this case because enabling it has a nontrivial impact in performance because SCEV is more conservative with select form and InductiveRangeCheckElimination isn't aware of select form of and/or i1.
      
      Reviewed By: nikic
      
      Differential Revision: https://reviews.llvm.org/D95026
      99108c79
    • Juneyoung Lee's avatar
      [LoopUnswitch] unswitch if cond is in select form of and/or as well · 5bb38e84
      Juneyoung Lee authored
      Hello all,
      I'm trying to fix unsafe propagation of poison values in and/or conditions by using
      equivalent select forms (`select i1 A, i1 B, i1 false` and `select i1 A, i1 true, i1 false`)
      instead.
      D93065 has links to patches for this.
      
      This patch allows unswitch to happen if the condition is in this form as well.
      `collectHomogenousInstGraphLoopInvariants` is updated to keep traversal if
      Root and the visiting I matches both m_LogicalOr()/m_LogicalAnd().
      Other than this, the remaining changes are almost straightforward and simply replaces
      Instruction::And/Or check with match(m_LogicalOr()/m_LogicalAnd()).
      
      Reviewed By: nikic
      
      Differential Revision: https://reviews.llvm.org/D97756
      5bb38e84
  2. Mar 07, 2021