[PATCH] D124742: [MIPS] Correct the implementation of the msub optimization

Simon Dardis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 1 13:06:08 PDT 2022


sdardis created this revision.
Herald added subscribers: atanasyan, jrtc27, hiraditya, arichardson.
Herald added a project: All.
sdardis requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The MIPS backend attempts to combine integer multiply and addition or
subtraction into a madd or msub operation. This optimization is
heavily restricted due to its utility in many cases.

PR/51114 highlighted that the optimization was performed on an
associative basis which is correct in the `add` case but not in
the `sub` case.

Resolve this bug by performing an early exit in the case where the
multiply is the LHS operand of the subtraction.

This resolves PR/51114.

Thanks to digitalseraphim for reporting the issue!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124742

Files:
  llvm/lib/Target/Mips/MipsISelLowering.cpp
  llvm/test/CodeGen/Mips/madd-msub.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124742.426308.patch
Type: text/x-patch
Size: 3012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220501/acd5f856/attachment.bin>


More information about the llvm-commits mailing list