[PATCH] D133417: [RISCV] Added optimization patterns with Zbb extension

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 08:24:03 PDT 2022


craig.topper added a comment.

In D133417#3776651 <https://reviews.llvm.org/D133417#3776651>, @iabg-sc wrote:

> This patch specific for RISCV. There is no guarantee that min/max will work faster than two comparisons on other archs.

I meant RISC-V DAGCombine in RISCVISelLowering not the generic DAGCombiner.

> I am not sure how count of the instructions can be increased as pattern explicitly specifies changes from three instructions to two (or three) instructions. Could you please give an example?

If the setccs have users other than the or/and, then they'll get selected by your pattern as well as the setcc only patterns to satisify the other users. Overall this would result in 4(2 from your pattern and 1 for each setcc) instructions being created instead of 3 if we had selected the OR and setcc separately.

> xori can be optimized later, but it requires more complex analysis than I suggest in this patch.

We already have a combine to fold the xori into a beqz or bnez by inverting the branch condition. We also have several combines that can pull the xori through a later or/and using deMorgan's law to move it closer to a branch.

> Right now I am trying to write self-expanding patterns in TableGen to support most cases.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133417



More information about the llvm-commits mailing list