Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIE2P] Support wide vector postinc 2D/3D, and offset load/store #323

Open
wants to merge 2 commits into
base: aie-public
Choose a base branch
from

Conversation

abnikant
Copy link
Collaborator

  1. Enable combine_load_store_increment, combine_offset_load_store_ptradd and combine_offset_load_store_share_ptradd
  2. Support wide vector POSTINC, POSTINC_2D, POSTINC_3D load and store.
  3. Fixup , offset opcode.
  4. Enable fifo combined load/store incr and offset load/store for 512-bits.
  5. Add tests for combining and load/store.

# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# (c) Copyright 2023-2024 Advanced Micro Devices, Inc. or its affiliates
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2025

@@ -58,7 +58,10 @@ MachineInstr *findPreIncMatch(MachineInstr &MemI, MachineRegisterInfo &MRI,
const AIEBaseInstrInfo &TII) {
// This is currently done with patterns in instruction selection.
// No need to do it here.
if (MRI.getType(MemI.getOperand(0).getReg()).getSizeInBits() >= 1024)
MachineFunction &MF = *MemI.getMF();
bool isAIE2 = MF.getTarget().getTargetTriple().isAIE2();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -320,9 +323,11 @@ MachineInstr *findPostIncMatch(MachineInstr &MemI, MachineRegisterInfo &MRI,
const AIEBaseInstrInfo &TII) {
if (!EnablePostIncCombine)
return nullptr;
if (MRI.getType(MemI.getOperand(0).getReg()).getSizeInBits() >= 1024)
MachineFunction &MF = *MemI.getMF();
bool isAIE2 = MF.getTarget().getTargetTriple().isAIE2();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const

; CHECK-NEXT: bb.1:
; CHECK-NEXT: successors: %bb.1(0x80000000)
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[PHI:%[0-9]+]]:_(p0) = G_PHI [[COPY]](p0), %bb.0, %2(p0), %bb.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, here we have just %2 instead of the regex.

: AIE2P::VLDA_dmx_lda_fifohl_idx;
return {ISelOpcode, FitsImmediateRange,
/*OffsetOpcode=*/AIE2P::VLDA_dmx_lda_fifohl_idx_imm};
}
llvm_unreachable("512-bit vector type must be in AccRegBank or VRegBank");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: ...or FifoRegBank

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -252,6 +252,11 @@ unsigned AIE2PInstrInfo::getOffsetMemOpcode(unsigned BaseMemOpcode) const {
llvm_unreachable("not a generic load/store");
}

bool AIE2PInstrInfo::isOffsetMemOpcode(unsigned Opcode) const {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: isGenericMemOffsetOpcode

Copy link
Collaborator Author

@abnikant abnikant Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the name.

@abnikant abnikant force-pushed the aie2p.wide.ld.st.incr.offset branch 2 times, most recently from 9d70b1d to a9baa70 Compare January 31, 2025 11:36
MachineFunction &MF = *MemI.getMF();
const bool isAIE2 = MF.getTarget().getTargetTriple().isAIE2();
if (isAIE2 &&
MRI.getType(MemI.getOperand(0).getReg()).getSizeInBits() >= 1024)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be a corresponding size check for AIE2P?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I have added a check but I don't expect the vector size to be greater that 2048-bits.

@@ -253,6 +253,11 @@ unsigned AIE2PInstrInfo::getOffsetMemOpcode(unsigned BaseMemOpcode) const {
llvm_unreachable("not a generic load/store");
}

bool AIE2PInstrInfo::isGenericOffsetMemOpcode(unsigned Opcode) const {
return ((Opcode == AIE2P::G_AIE_OFFSET_STORE) ||
(Opcode == AIE2P::G_AIE_OFFSET_LOAD));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about G_AIE_OFFSET_SEXTLOAD / G_AIE_OFFSET_ZEXTLOAD ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@abnikant abnikant force-pushed the aie2p.wide.ld.st.incr.offset branch from a9baa70 to 48a5ce8 Compare January 31, 2025 14:46
; CHECK-NEXT: vst lfl0, [p1, #0] // Delay Slot 4
; CHECK-NEXT: vst lfh0, [p1, #64] // Delay Slot 3
; CHECK-NEXT: nop
; CHECK-NEXT: nop
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can the vst not work on the fifo registers as before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understood the question but if your question is why the test is updated ? since MIR is updated after the load/store combiner is enabled, it uses G_AIE_POSTINC_STORE.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a vst post increment that works on fifo regs? Because that would be preferable in this situation

@abnikant abnikant force-pushed the aie2p.wide.ld.st.incr.offset branch from 48a5ce8 to c82ccd3 Compare January 31, 2025 16:21
; CHECK-NEXT: vst sfl, [p1, #0] // Delay Slot 4
; CHECK-NEXT: vst sfh, [p1, #64] // Delay Slot 3
; CHECK-NEXT: nop
; CHECK-NEXT: vmov x1, sfh
Copy link
Collaborator

@andcarminati andcarminati Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess @F-Stuckmann is referring to this case. Now we are storing using vector registers.

Copy link
Collaborator Author

@abnikant abnikant Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do have the post-increment for fifo-regs , refer to the test case inst-select-vector-pre-post-increment.mir. The problem with the above case is register bank assignment not assigning fiforegbank.

%7:ptrregbank(p0), %8:fiforegbank(<32 x s32>), %9:gprregbank(s32) = G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.aie2p.fifo.ld.fill), %4(p0), %5(<32 x s32>), %6(s32)
%10:vregbank(<32 x s32>) = COPY %8(<32 x s32>)
%3:ptrregbank(p0) = G_AIE_POSTINC_STORE %10(<32 x s32>), %1, %2(s20) :: (store (<32 x s32>) into %ir.s)

if I use %8 in G_AIE_POSTINC_STORE , then it generates post-inc with fifo. We are missing G_AIE_POSTINC_STORE opcode in regbank-select.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants