[PATCH] D115602: [X86] Memset is lowered to rep stos if MinSize is present

Daniil Seredkin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 16 07:45:44 PST 2021


vdsered added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h:80-92
   /// Emit target-specific code that performs a memset.
   /// This can be used by targets to provide code sequences for cases
   /// that don't fit the target's parameters for simple stores and can be more
   /// efficient than using a library call. This function can return a null
   /// SDValue if the target declines to use custom code and a different
   /// lowering strategy should be used.
   virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl,
----------------
lebedev.ri wrote:
> Why do you need `shouldEmitTargetCodeForMemset()` if there already is `EmitTargetCodeForMemset`?
1) EmitTargetCodeForMemset seems to me to be the best place to generate code specific to MinSize for a target
2) I intended to avoid changing/touching code generation for other backends which do not want to handle cases like MinSize or something similar and I thought of a way to go directly to EmitTargetCodeForMemset
3) I optimize for MinSize when the length is constant and for such a case there is another lowering in getMemsetStores and I need to skip it

So, I created a method to decide whether to go directly to EmitTargetCodeForMemset or not and this method is customizable for each target.

There is probably a better solution, but I don't see a way to do it with less code written. Any suggestions? I can clarify it better in the comments...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115602



More information about the llvm-commits mailing list