Skip to content

Commit 892ac61

Browse files
fhossein-quiciajbarKrzysztof Parzyszek
authored
Add HexagonGlobalScheduler pass (#180803)
This patch adds the HexagonGlobalScheduler, a post-packetization pass that performs global instruction scheduling and pull-up optimizations to improve packet density on Hexagon VLIW architecture. The scheduler operates on scheduling regions (super-blocks with single entry and multiple exits) and attempts to move instructions across basic blocks to fill packet slots more efficiently. It supports both speculative and predicative scheduling modes. Key features: - Global instruction scheduling across basic blocks - Speculative scheduling with safety checks - Predicative scheduling using predication - Local pull-up within basic blocks - Dual jump formation - Branch optimizations - Liveness preservation using HexagonLiveVariables The pass depends on HexagonLiveVariables and HexagonGlobalRegion infrastructure for maintaining correct liveness information when moving instructions across basic block boundaries. This patch also adds two helper functions to HexagonRegisterInfo that are required by the scheduler to prevent correctness issues. 1. isGlobalReg(MCPhysReg Reg) - Returns true for reserved physical registers (R29, R30, R31) that are live across function calls. This prevents the scheduler from incorrectly speculating instructions that modify the stack pointer or frame pointer. 2. isFakeReg(MCPhysReg Reg) - Returns true for fake HVX registers (VF0-VF31, VFR0-VFR31) used as sub-registers in vector pairs. This prevents crashes when the scheduler processes HVX vector operations by skipping these internal bookkeeping registers. The scheduler runs in the pre-emit pipeline after packetization and is only active when optimizations are enabled. Patch by Sergei Larin <slarin@qti.qualcomm.com> Co-authored-by: Ikhlas Ajbar <iajbar@qti.qualcomm.com> Co-authored-by: Krzysztof Parzyszek <kparzysz@codeaurora.org>
1 parent 637e9bd commit 892ac61

16 files changed

+7711
-4
lines changed

llvm/lib/Target/Hexagon/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ add_llvm_target(HexagonCodeGen
3939
HexagonGenMux.cpp
4040
HexagonGenPredicate.cpp
4141
HexagonGlobalRegion.cpp
42+
HexagonGlobalScheduler.cpp
4243
HexagonLiveVariables.cpp
4344
HexagonHardwareLoops.cpp
4445
HexagonHazardRecognizer.cpp

llvm/lib/Target/Hexagon/Hexagon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void initializeHexagonEarlyIfConversionPass(PassRegistry &);
4141
void initializeHexagonExpandCondsetsPass(PassRegistry &);
4242
void initializeHexagonGenMemAbsolutePass(PassRegistry &);
4343
void initializeHexagonGenMuxPass(PassRegistry &);
44+
void initializeHexagonGlobalSchedulerPass(PassRegistry &);
4445
void initializeHexagonHardwareLoopsPass(PassRegistry &);
4546
void initializeHexagonLiveVariablesPass(PassRegistry &);
4647
void initializeHexagonLoopIdiomRecognizeLegacyPassPass(PassRegistry &);
@@ -94,6 +95,7 @@ FunctionPass *createHexagonGenInsert();
9495
FunctionPass *createHexagonGenMemAbsolute();
9596
FunctionPass *createHexagonGenMux();
9697
FunctionPass *createHexagonGenPredicate();
98+
FunctionPass *createHexagonGlobalScheduler();
9799
FunctionPass *createHexagonHardwareLoops();
98100
FunctionPass *createHexagonISelDag(HexagonTargetMachine &TM,
99101
CodeGenOptLevel OptLevel);

0 commit comments

Comments
 (0)