-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: aie-public
Are you sure you want to change the base?
Conversation
abnikant
commented
Jan 31, 2025
- Enable combine_load_store_increment, combine_offset_load_store_ptradd and combine_offset_load_store_share_ptradd
- Support wide vector POSTINC, POSTINC_2D, POSTINC_3D load and store.
- Fixup , offset opcode.
- Enable fifo combined load/store incr and offset load/store for 512-bits.
- 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 |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: const
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: ...or FifoRegBank
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: isGenericMemOffsetOpcode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the name.
9d70b1d
to
a9baa70
Compare
MachineFunction &MF = *MemI.getMF(); | ||
const bool isAIE2 = MF.getTarget().getTargetTriple().isAIE2(); | ||
if (isAIE2 && | ||
MRI.getType(MemI.getOperand(0).getReg()).getSizeInBits() >= 1024) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
a9baa70
to
48a5ce8
Compare
; CHECK-NEXT: vst lfl0, [p1, #0] // Delay Slot 4 | ||
; CHECK-NEXT: vst lfh0, [p1, #64] // Delay Slot 3 | ||
; CHECK-NEXT: nop | ||
; CHECK-NEXT: nop |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
48a5ce8
to
c82ccd3
Compare
; 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.