強化壓縮指令集的暫存器配置演算法
OptiCompressRA: Enhanced Register Allocation for Compressed ISAs
摘要
現今的電腦架構主要分成兩個種類,分別是 CSIC 和 RISC。RISC 希望所有的指令 行為簡單並且設計明瞭,並且通常指令長度也相同。然而,因為 RISC 指令集大多都 有指令要等長的限制,使得某些不需要這麼長的指令必須要在某些位置填補一些沒有 意義的字符,也因此 RISC 指令集相比 CISC 常常有較大的程式尺寸的問題。為了解決 這個問題,大部分的 RISC 指令集幾乎都有各自的壓縮指令集以減少程式大小。然而, 現今的編譯器都沒有在編譯時將這些指令集提供的優化納入考慮,而是在編譯完成後 將可以轉換的指令進行壓縮。先前的一個研究提出了考量壓縮指令的暫存器配置演算 法,透過在指派暫存器的同時考慮指令被壓縮的可能性,在 SPEC2017 上和 LLVM -O3 比較,可以獲得 1.37% 的程式縮減。然而,考量壓縮指令的暫存器配置演算法有其問 題存在。在計算虛擬變數 (virtual register) 的壓縮可行性時,考量壓縮指令的暫存器配 置演算法傾向樂觀的將所有的虛擬變數都當作有機會被壓縮,但其實有些虛擬變數在 當前指令之後還有被使用,把當前指令壓縮可能造成更嚴重的額外成本。另外,在指 派暫存器時,考量壓縮指令的暫存器配置演算法希望可以先指派暫存器給需要佔用暫 存器比較長時間的虛擬變數,不過這麼做可能會有問題,原因在於並非所有佔用時間 較長的虛擬變數被指派到壓縮指令暫存器 (C register) 都會有好處。反而,如果將這些 虛擬變數指派到這些暫存器可能會使得其他有好處的虛擬變數沒有辦法獲得好處。我 們提出了強化壓縮指令集的暫存器配置演算法來解決以上兩個問題。強化壓縮指令集 的暫存器配置演算法的核心概念在於配置暫存器時會先更審慎考量虛擬變數被壓縮的 可行性,只有在壓縮可行性較大的時候可以先指派到壓縮指令暫存器。實驗結果顯示, 與考量壓縮指令的暫存器配置演算法相比,強化壓縮指令集的暫存器配置演算法在 polybench 上平均可以達到 0.89% 的程式縮減 (最高可達 1.64%),同時在 SPEC2017 上 平均可以達到 0.3% 的程式縮減 (最高可達 1.71%)。
The modern landscape of computer architectures is characterized by the contrasting paradigms of complex instruction set computer (CISC) and reduced instruction set computer (RISC). While both approaches aim to streamline instruction execution, they diverge significantly in their treat- ment of instruction sets. RISC architectures prioritize simplicity and uniformity, often lead- ing to fixed-length instructions that may require padding. To mitigate the resultant increase in program size, many RISC instruction set architectures (ISAs), e.g., ARM and RISC-V, in- corporate compressed instruction sets. Current practices mainly rely on post-compilation com- pression techniques rather than integrating compression optimization into the compilation pro- cess itself. Previous research efforts have introduced a compression-aware register allocator, which we refer to as CompressRA. However, CompressRA tends to overestimate compres- sion potential and may allocate registers suboptimally, thereby limiting its effectiveness. In response to these challenges, we present OptiCompressRA, an innovative register allocator tai- lored for compressed ISAs. OptiCompressRA adopts a meticulous approach to assess com- pression feasibility during the register allocation phase, thereby enhancing the efficiency of compression-aware techniques. Experimental evaluations conducted on benchmarks, including Polybench and SPEC2017, demonstrate promising results for RISC-V architectures. On Poly- bench, we observed an average program size reduction of 0.89% (with peaks reaching 1.64%), and on SPEC2017, a reduction of 0.3% (with peaks reaching 1.71%), compared to existing compression-aware methodologies. By integrating compression optimization seamlessly into the register allocation process, OptiCompressRA represents a significant advancement in en- hancing program efficiency and resource utilization within RISC architectures. This research underscores the importance of holistic optimization strategies in maximizing the benefits of compressed instruction sets, thereby paving the way for more efficient and scalable computing systems.