-
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
Add ZOL to aie2p #311
base: aie-public
Are you sure you want to change the base?
Add ZOL to aie2p #311
Conversation
e7a3319
to
c83208c
Compare
// LoopStart carries an immediate operand that is dedicated to the tripcount | ||
// update of the pipeliner. We translate to ADD_NC, which has a similar | ||
// operand. | ||
BuildMI(*MBB, Start, Start->getDebugLoc(), TII->get(AIE2::ADD_NC), AIE2::LC) |
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.
This was not generic, but we only need the right numbers. They are now supplied by one single getZOLSupport() call.
c83208c
to
21a95b9
Compare
LLVMContext &C = L->getHeader()->getContext(); | ||
HWLoopInfo.CountType = Type::getInt32Ty(C); | ||
HWLoopInfo.LoopDecrement = ConstantInt::get(HWLoopInfo.CountType, 1); | ||
// We always allow nested hardware loops, but only the innermost loop |
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.
Yeah right. Note how we only allow single block loops above. Details.
@@ -221,35 +245,31 @@ struct AIEBaseInstrInfo : public TargetInstrInfo { | |||
// Opcodes related to hardware loop handling | |||
virtual bool isHardwareLoopDec(unsigned Opcode) const { return false; } | |||
virtual bool isHardwareLoopJNZ(unsigned Opcode) const { return false; } | |||
virtual bool isHardwareLoopStart(unsigned Opcode) const { return false; } | |||
virtual bool isHardwareLoopEnd(unsigned Opcode) const { return false; } | |||
virtual bool isHardwareLoopStart(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.
This completely stands on the base class now. I hope no need to override this in the future ;-)
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. The base class will work if there's a fixed set of opcodes that is used in all occurrences. I expect this to remain true.
HWLoopInfo.CounterInReg = true; | ||
} | ||
return true; | ||
} |
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: new line.
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// (c) Copyright 2023-2025 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.
Should this be only 2025?
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.
No. This file was copied, then modified.
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "AIE2PTargetTransformInfo.h" |
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.
For the future (really not now): refactor this to a common class.
extern cl::opt<unsigned> MaxUnrollCost; | ||
extern cl::opt<unsigned> PreferSwpOverUnroll; | ||
|
||
void AIE2PTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE, |
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 really needed by this PR, but a nice-to-have change.
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 got it for free, and it made getting an end-to-end postpiperliner test working a lot eaesier.
General comment: looks good, just some outdated dates. |
21a95b9
to
d0caf34
Compare
Result.LoopEndOpcode = AIE2::PseudoLoopEnd; | ||
Result.SetLoopCountOpcode = AIE2::ADD_NC; | ||
Result.SetAddressOpcode = AIE2::MOVXM_lng_cg; | ||
Result.LoopSetupDistance = 7; |
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: Would be nice if you could comment on this number.
@@ -329,6 +329,14 @@ bool AIEBaseInstrInfo::isCallBundle(MachineBasicBlock::iterator MII) const { | |||
return IsReturnAddr; | |||
} | |||
|
|||
bool AIEBaseInstrInfo::isZOLTripCountDef(const MachineInstr &MI, |
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: May be you dont need this to be virtual function anymore.
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.
Murphy law, in the formulation "Constants aren't, variables won't": if I leave it I will never need it; if I remove it, I will need it next week.
bool AIEBaseInstrInfo::isZeroOverheadLoopSetupInstr( | ||
const MachineInstr &MI) const { | ||
auto ZOLSupport = getZOLSupport(); | ||
if (!ZOLSupport) { |
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.
cant we just assert like in getLoopSetupDistance
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.
No. We are a simple predicate that returns whether this is a ZOLsetup instruction. If we haven't got ZOLSupport, it isn't one. No reason to abort.
%12:_(s32) = nsw G_ADD %4, %11 | ||
G_STORE %12(s32), %0(p0) :: (store (s32)) | ||
%14:_(s32) = nuw nsw G_ADD %5, %13 | ||
%15:_(s1) = G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.loop.decrement), %13(s32) |
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 need this entire loop to test this? can we simply use %15:_(s1) = G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.loop.decrement), %13(s32)
select_BRCOND cs has been refactored to BaseInstructionSelector
Put it in a separate source file
Cleanup of includes
d0caf34
to
e56871b
Compare
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.
LGTM. All relevant refactorings were included and all comments addressed.
@martien-de-jong I can see many ZOL tests for aie2 |
Leveraged the great similarity between aie2 and aie2p. All of ZOL can now be defined by a dozen of opcodes, registers and other numbers