[PATCH] D149260: [AArch64] Emit FNMADD instead of FNEG(FMADD)

Matt Devereau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 5 05:35:36 PDT 2023


MattDevereau updated this revision to Diff 519817.
MattDevereau edited the summary of this revision.
MattDevereau added a comment.

When I pushed the previous revision it produced bad machine code which triggered failures.
Previously I created a new variable MAD for capturing old FMADD instructions and used this variable
to merge the FMADD flags with the FNEG flags, however I did not mark it for deletion like the MUL did, i.e.

    } // end switch (Pattern)
    // Record MUL and ADD/SUB for deletion
    if (MUL)
      DelInstrs.push_back(MUL);
    DelInstrs.push_back(&Root);
  
    // Set the flags on the inserted instructions to be the merged flags of the
    // instructions that we have combined.
    uint16_t Flags = Root.getFlags();
    if (MUL)
      Flags = Root.mergeFlagsWith(*MUL);
    if (MAD)
      Flags = Root.mergeFlagsWith(*MAD);
    for (auto *MI : InsInstrs)
      MI->setFlags(Flags);
  }

Instead I have used the MUL variable to capture the MAD, and that emits clean machine code.
I have also added `-verify-machineinstrs` to the test to verify the machine code does not regress.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149260

Files:
  llvm/include/llvm/CodeGen/MachineCombinerPattern.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/test/CodeGen/AArch64/aarch64_fnmadd.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149260.519817.patch
Type: text/x-patch
Size: 8279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230505/e89e2b63/attachment.bin>


More information about the llvm-commits mailing list