[PATCH] D133300: [InstCombine] Matrix multiplication negation optimisation

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 16 08:43:03 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:1890
+      replaceInstUsesWith(*II, FNegInst);
+      FNegInst->setOperand(0, II);
+      return II;
----------------
This sequence of create/replace/reset operand seems shaky. This transform is different than the earlier ones because we are creating a new instruction after the existing matmul call. 

It would be better to use the standard practice: Builder.CreateIntrinsic() followed by UnaryOperator::CreateFNeg().

This is also dropping all FMF on the fneg. Usually, we'd propagate the FMF from the matmul to the new fneg. We should adjust the tests to show this behavior more explicitly (ie, put some FMF on the fnegs in the tests).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133300



More information about the llvm-commits mailing list