[PATCH] D108871: [AArch64] Implement target hook function to decide folding (mul (add x, c1), c2)
Ben Shi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 3 08:09:48 PDT 2021
benshi001 marked an inline comment as done.
benshi001 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");
----------------
dmgreen wrote:
> 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?
Thanks for your suggestion. Using `AArch64_IMM::expandMOVImm` makes the check more clear and accurate !!!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108871/new/
https://reviews.llvm.org/D108871
More information about the llvm-commits
mailing list