================
@@ -99,63 +203,90 @@ static bool lowerTileCopy(MachineFunction &MF) {
if (!X86::TILERegClass.contains(DstReg, SrcReg))
continue;
- // Allocate stack slot for tile register
+ // Allocate stack slot for tile register (1KB for ACE, same for AMX)
unsigned Size = TRI->getSpillSize(X86::TILERegClass);
Align Alignment = TRI->getSpillAlign(X86::TILERegClass);
int TileSS = MF.getFrameInfo().CreateSpillStackObject(Size, Alignment);
- int StrideSS = 0;
+ const DebugLoc &DL = MI.getDebugLoc();
- // Pick a killed register to avoid a save/reload.
- Register GR64Cand = X86::NoRegister;
- for (auto RegT : GR64Regs.set_bits()) {
- if (UsedRegs.available(RegT)) {
- GR64Cand = RegT;
- break;
+ // Palette 2 has no TILELOADD/TILESTORED, so copy the tile row-by-row
+ // through a scratch ZMM.
+ if (FuncInfo->getACEProgModel() == ACEProgModelEnum::ACE_ManagedRA) {
+ Register ScratchZMM = findScratchZMM(MF, TRI, UsedRegs);
+ int ZmmSS = -1;
+ if (!ScratchZMM) {
+ // No available register? Save ZMM0 and reload it after use.
+ ScratchZMM = X86::ZMM0;
+ ZmmSS = MF.getFrameInfo().CreateSpillStackObject(64, Align(64));
+ addFrameReference(BuildMI(MBB, MI, DL, TII->get(X86::VMOVUPSZmr)),
+ ZmmSS)
+ .addReg(X86::ZMM0);
}
- }
- const DebugLoc &DL = MI.getDebugLoc();
- if (GR64Cand) {
- // mov 64 %reg
- BuildMI(MBB, MI, DL, TII->get(X86::MOV64ri), GR64Cand).addImm(64);
+ emitACETileSpill(MBB, MI, TII, SrcReg, SrcMO.isKill(), TileSS,
+ ScratchZMM);
+ emitACETileReload(MBB, MI, TII, DstReg, TileSS, ScratchZMM);
+
----------------
ganeshgit wrote:
Upstream defines only the read direction of `TILEMOVROW` (tile → ZMM), so on
AMX the only way to materialize a tile is `TILELOADD` from memory, and the pass
is built around allocating a spill slot and not to break the AMX flow.
ACE adds the missing direction, so the stack is no longer needed for a
tile-to-tile copy! Its redundant. I will post a commit for this!
https://github.com/llvm/llvm-project/pull/208408
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits