具有置换指令的最优混洗码
Optimal Shuffle Code with Permutation Instructions
摘要:
在程序编译期间,寄存器分配是将程序变量映射到机器寄存器的任务。在寄存器分配期间,编译器可能会引入混洗代码,包括复制和交换操作,在寄存器之间传输数据。混洗代码的三个常见来源是在程序的控制流中的连接处的冲突寄存器映射,例如,由于if语句或循环;过程的调用约定,其通常规定输入参数或结果必须放置在某些寄存器中;以及只允许寄存器的子集作为操作数出现的机器指令。最近,Mohr等人提出用特殊的硬件指令来加速shuffle代码,这些指令可以任意排列多达五个寄存器的内容,并给出了计算这种shuffle代码的启发式方法。本文给出了一个在Mohr等人的设定下产生最优混洗码的有效算法。当没有寄存器必须被转移到一个以上的目的地时,会出现一个有趣的特殊情况,即,置换寄存器的内容就足够了。这种情况等价于将一个置换分解为置换的最小乘积,其中每个置换最多可置换五个元素。
英文摘要:
During compilation of a program, register allocation is the task of mapping program variables to machine registers. During register allocation, the compiler may introduce shuffle code, consisting of copy and swap operations, that transfers data between the registers. Three common sources of shuffle code are conflicting register mappings at joins in the control flow of the program, e.g, due to if-statements or loops; the calling convention for procedures, which often dictates that input arguments or results must be placed in certain registers; and machine instructions that only allow a subset of registers to occur as operands. Recently, Mohr et al. proposed to speed up shuffle code with special hardware instructions that arbitrarily permute the contents of up to five registers and gave a heuristic for computing such shuffle codes. In this paper, we give an efficient algorithm for generating optimal shuffle code in the setting of Mohr et al. An interesting special case occurs when no register has to be transferred to more than one destination, i.e., it suffices to permute the contents of the registers. This case is equivalent to factoring a permutation into a minimal product of permutations, each of which permutes up to five elements.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。