[PATCH] D101840: [InstSimplify] ctlz(x) -> 0 if x is known negative number

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 4 12:27:54 PDT 2021


xbolva00 added a comment.

>> // FIXME: This should be in InstSimplify because we're replacing an ...

Not sure, if we want to then compute known bits in instcombine just for:

  if (!Known.One.isNullValue() ||
      isKnownNonZero(Op0, IC.getDataLayout(), 0, &IC.getAssumptionCache(), &II,
                     &IC.getDominatorTree())) {
    if (!match(II.getArgOperand(1), m_One()))
      return IC.replaceOperand(II, 1, IC.Builder.getTrue());
  }

For now I think I will move this code to instcombine.

>> Enhance isKnownNegative to know that ashr of negative constant is still negative? Then we could remove the match here.

In this case, please feel free to enhance computeKnownBits/computeSignBits.


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

https://reviews.llvm.org/D101840



More information about the llvm-commits mailing list