[PATCH] D117110: [InstCombine] try to fold binop with phi operands

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 12 07:46:20 PST 2022


spatel added a comment.

In D117110#3237366 <https://reviews.llvm.org/D117110#3237366>, @lebedev.ri wrote:

> What about the case where one PHI is fully constant: https://godbolt.org/z/16W8oGYv3 ?

Hmm...so we convert that into a binop with constant operand, and I thought we'd then get that pattern within InstCombinerImpl::foldOpIntoPhi(). But there's an extra clause in that code that is likely also needed here:

  // If there is exactly one non-constant value, we can insert a copy of the
  // operation in that block.  However, if this is a critical edge, we would be
  // inserting the computation on some other paths (e.g. inside a loop).  Only
  // do this if the pred block is unconditionally branching into the phi block.
  // Also, make sure that the pred block is not dead code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117110/new/

https://reviews.llvm.org/D117110



More information about the llvm-commits mailing list