Assembly (MIPS)某些汇编指令是否比其他指令更快?

Assembly (MIPS)某些汇编指令是否比其他指令更快?,assembly,mips,Assembly,Mips,某些裸MIPS指令是否比其他指令更快?引发我兴趣的问题是将寄存器乘以2的幂 假设$t0有一个不会溢出的数字。如果我想将该寄存器乘以8,以下各项之间是否存在可量化的性能差异: 3位sll: sll $t0, $t0,3 mul $t0, $t0,$t8 使用mul命令(假设$t8的值为8): sll $t0, $t0,3 mul $t0, $t0,$t8 或使用mult命令? mult $t0, $t0

某些裸MIPS指令是否比其他指令更快?引发我兴趣的问题是将寄存器乘以2的幂

假设$t0有一个不会溢出的数字。如果我想将该寄存器乘以8,以下各项之间是否存在可量化的性能差异:

3位sll:

    sll     $t0,  $t0,3
    mul     $t0,  $t0,$t8
使用mul命令(假设$t8的值为8):

    sll     $t0,  $t0,3
    mul     $t0,  $t0,$t8
或使用mult命令?

    mult    $t0,  $t0,$t8
每个示例都由一条指令组成,但我不知道其中一条是否比另一条快。直觉让我认为mul比mult快,因为并没有多余的比特存储到HI中(对吗?)

或者,是否有人知道关于汇编中单个指令速度(MIPS或其他)主题的任何文章/网页?我可以想象,不同的指令由不同的电路/硬件组成,每个指令在不同的时间内执行,但我似乎无法在网上找到任何有关这方面的资源


我对MIPS/assembly非常陌生,因此请原谅我没有运行计时示例(或者在上面的示例中可能使用了不正确的语法)。

MIPS32TM程序员体系结构 第二卷:MIPS32TM指令集,mul/mult指令集

Programming Notes:
In some processors the integer multiply operation may proceed asynchronously and allow other CPU instructions to
execute before it is complete. An attempt to read LO or HI before the results are written interlocks until the results are
ready. Asynchronous execution does not affect the program result, but offers an opportunity for performance
improvement by scheduling the multiply so that other instructions can execute in parallel.
Programs that require overflow detection must check for it explicitly.
Where the size of the operands are known, software should place the shorter operand in GPR rt. This may reduce the
latency of the instruction on those processors which implement data-dependent instruction latencies.
因此,是的,在MIPS中,任意数的乘法是极少数比其他指令占用更多周期的事情之一。
按照手册中指定的
mul
,可以实现为
mult
,然后
mflo
,在这种情况下,
mul
mult
显然具有完全相同的定时特性

它也可能真正是一条单独的指令,在这种情况下,它可能更快(可能至少出于功耗原因而避免计算高半衰期),但我怀疑很少有硬件实现这样做。

乘法/除法单元是MIPS体系结构中较差的方面之一。

mult
需要2个操作数。
hi:lo
输出是隐式的。