[PATCH] D108871: [AArch64] Implement target hook function to decide folding (mul (add x, c1), c2)

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 3 06:28:51 PDT 2021


dmgreen added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:12152
+// Return true if Imm can be composed by a single MOVZ instruction.
+static inline bool isMOVZImm(uint64_t Imm, unsigned Sz) {
+  assert((Sz == 64) || (Sz == 32) && "invalid immediate size");
----------------
benshi001 wrote:
> benshi001 wrote:
> > dmgreen wrote:
> > > Can this use AArch64TTIImpl::getIntImmCost in some way?
> > I think it is hard. Since the  API
> > 
> > ```
> > TargetTransformInfo
> > AArch64TargetMachine::getTargetTransformInfo(const Function &F) {
> >   return TargetTransformInfo(AArch64TTIImpl(this, F));
> > }
> > ```
> > 
> > requires a `Function` object, but the target hook has only two `SDValue` parameters.
> > 
> > So the cheapest way is implementing a new but short `isMOVZImm` helper function.
> I have simplified it to one additional helper function.
It's more about not repeating the same (or similar) code. Can this at least use AArch64_IMM::expandMOVImm and check the number of instructions?


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

https://reviews.llvm.org/D108871



More information about the llvm-commits mailing list