[llvm] 090f8ec - [Hexagon] Fix some issues with packetizing slot0-only instructions
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 4 14:39:53 PST 2022
Author: Brendon Cahoon
Date: 2022-01-04T14:35:37-08:00
New Revision: 090f8ec8a8dc31ac4402f345ed79462de9b3dc01
URL: https://github.com/llvm/llvm-project/commit/090f8ec8a8dc31ac4402f345ed79462de9b3dc01
DIFF: https://github.com/llvm/llvm-project/commit/090f8ec8a8dc31ac4402f345ed79462de9b3dc01.diff
LOG: [Hexagon] Fix some issues with packetizing slot0-only instructions
Added:
Modified:
llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp
llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp
index 0f736a189245..e9b658d18175 100644
--- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp
@@ -886,7 +886,8 @@ bool HexagonPacketizerList::canPromoteToDotNew(const MachineInstr &MI,
// Create a dot new machine instruction to see if resources can be
// allocated. If not, bail out now.
- int NewOpcode = HII->getDotNewOp(MI);
+ int NewOpcode = (RC != &Hexagon::PredRegsRegClass) ? HII->getDotNewOp(MI) :
+ HII->getDotNewPredOp(MI, MBPI);
const MCInstrDesc &D = HII->get(NewOpcode);
MachineInstr *NewMI = MF.CreateMachineInstr(D, DebugLoc());
bool ResourcesAvailable = ResourceTracker->canReserveResources(*NewMI);
@@ -1107,6 +1108,11 @@ static bool cannotCoexistAsymm(const MachineInstr &MI, const MachineInstr &MJ,
HII.isHVXMemWithAIndirect(MI, MJ))
return true;
+ // Don't allow a store and an instruction that must be in slot0 and
+ // doesn't allow a slot1 instruction.
+ if (MI.mayStore() && HII.isRestrictNoSlot1Store(MJ) && HII.isPureSlot0(MJ))
+ return true;
+
// An inline asm cannot be together with a branch, because we may not be
// able to remove the asm out after packetizing (i.e. if the asm must be
// moved past the bundle). Similarly, two asms cannot be together to avoid
@@ -1526,6 +1532,13 @@ bool HexagonPacketizerList::isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) {
bool IsVecJ = HII->isHVXVec(J);
bool IsVecI = HII->isHVXVec(I);
+ // Don't reorder the loads if there is an order dependence. This would
+ // occur if the first instruction must go in slot0.
+ if (LoadJ && LoadI && HII->isPureSlot0(J)) {
+ FoundSequentialDependence = true;
+ break;
+ }
+
if (Slot1Store && MF.getSubtarget<HexagonSubtarget>().hasV65Ops() &&
((LoadJ && StoreI && !NVStoreI) ||
(StoreJ && LoadI && !NVStoreJ)) &&
@@ -1821,14 +1834,6 @@ bool HexagonPacketizerList::shouldAddToPacket(const MachineInstr &MI) {
if (Minimal)
return false;
- // Constrainst for not packetizing this MI with existing instructions in a
- // packet.
- // MI is a store instruction.
- // CurrentPacketMIs has a SLOT0 only instruction with constraint
- // A_RESTRICT_NOSLOT1_STORE/isRestrictNoSlot1Store.
- if (MI.mayStore() && isPureSlot0InsnWithNoSlot1Store(MI))
- return false;
-
if (producesStall(MI))
return false;
@@ -1868,18 +1873,6 @@ bool HexagonPacketizerList::shouldAddToPacket(const MachineInstr &MI) {
return true;
}
-bool HexagonPacketizerList::isPureSlot0InsnWithNoSlot1Store(
- const MachineInstr &MI) {
- bool noSlot1Store = false;
- bool isSlot0Only = false;
- for (auto J : CurrentPacketMIs) {
- noSlot1Store |= HII->isRestrictNoSlot1Store(*J);
- isSlot0Only |= HII->isPureSlot0(*J);
- }
-
- return (noSlot1Store && isSlot0Only);
-}
-
// V60 forward scheduling.
unsigned int HexagonPacketizerList::calcStall(const MachineInstr &I) {
// Check whether the previous packet is in a
diff erent loop. If this is the
diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.h b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.h
index 5d1b6d6faa12..6a709e566f86 100644
--- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.h
+++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.h
@@ -159,7 +159,6 @@ class HexagonPacketizerList : public VLIWPacketizerList {
bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J);
bool hasDualStoreDependence(const MachineInstr &I, const MachineInstr &J);
bool producesStall(const MachineInstr &MI);
- bool isPureSlot0InsnWithNoSlot1Store(const MachineInstr &MI);
unsigned int calcStall(const MachineInstr &MI);
};
More information about the llvm-commits
mailing list