[PATCH] D142084: [RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table

Bing Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 15 22:45:41 PDT 2023


yubing added a comment.

does unfolding only happen in LICM?



================
Comment at: llvm/utils/TableGen/X86FoldTablesEmitter.cpp:442
+    Result.CannotUnfold = BaseRegInst->isMoveReg ? true : Result.CannotUnfold;
+  } else if (RegInstr->isMoveReg && Result.IsStore)
     Result.CannotUnfold = true;
----------------
yubing wrote:
> skan wrote:
> > Why do we need `Result.IsStore` here?
> load such as VMOVAPDZ128rm will never be unfolded.
> if VMOVAPDZ128rm 's memoperand is invariant, then VMOVAPDZ128rm  will be hoisted directly and won't be unfolded into rm+rr
> if VMOVAPDZ128rm 's memoperand is not invariant, we stop doing unfolding since compiler find it is a simple load.
> ```
>   // First check whether we should hoist this instruction.
>   if (!IsLoopInvariantInst(*MI) || !IsProfitableToHoist(*MI)) {
>     // If not, try unfolding a hoistable load.
>     MI = ExtractHoistableLoad(MI);
>     if (!MI) return false;
>   }
> ```
> ```
> MachineInstr *MachineLICMBase::ExtractHoistableLoad(MachineInstr *MI) {
>   // Don't unfold simple loads.
>   if (MI->canFoldAsLoad())
>     return nullptr;
> 
> ```
> @craig.topper , does line429~439 make sense to you as well?
@craig.topper i think my analysis of VMOVAPDZ128rm is only for LICM. but for other passes in codegen, is it possible for VMOVAPDZ128rm to be unfolded?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142084



More information about the llvm-commits mailing list