PowerPC 上的条件移动
PowerPC(32 或 64)指令集上是否有等效的条件移动?显然可以使用条件分支来模拟它,但我想要一些性能优于它的东西。
Is there a conditional-move-equivalent on the PowerPC (32 or 64) instruction set? It can obviously be emulated using a conditional branch, but I want something that outperforms that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
PowerPC 至少有一个浮点条件移动操作 fsel,其工作方式如下:
对于整数值,您可以使用位掩码来“选择”要使用的值。
这是关于此主题的讨论(底部的整数)
PowerPC has at least a floating-point conditional move operation, fsel, which works like follows:
For Integer values, you could use bit masks to "select" which value to use.
Here's a discussion on this topic (integer at the bottom)
请记住,PowerPC 是 RISC,因此指令集故意简单。不过,您可以在 IBM“PowerPC Compiler Writer's Guide”(ISBN 0-9649654-0-2)中找到有用的提示 - 有许多条件序列(例如 max/min)的无分支实现示例,它们可能会给您一些想法。
另外,如果您有 AltiVec,并且您的代码可以矢量化,那么使用比较和 vec_sel 等条件移动就非常容易。
Remember that PowerPC is RISC, so the instruction set is intentionally simple. You can find useful tips in the IBM "PowerPC Compiler Writer’s Guide" (ISBN 0-9649654-0-2) though - there are a number of examples of branchless implementations of conditional sequences (e.g. max/min) which might give you some ideas.
Also, if you have AltiVec, and your code can be vectorised, then conditional moves are very easy using e.g. compares and
vec_sel
.对于 NaN 和 Inf 等异常值,单独使用
fsel
通常会导致错误的结果。您必须仔细考虑每次比较的结果。整数选择已在 PowerPC 的至少两个变体中实现。
IBM 在其 AS/400 系统中具有
selii
、selir
、selri
、selrr
指令。这些可以为每个源在寄存器或带符号的 5 位立即数之间进行选择。该决定基于 AS/400 特定的寄存器。Motorola/Freescale 在 e200 和 e500 系列(可能还有其他系列)中使用了“isel APU”。它们使用常规条件寄存器位,但只能从寄存器源中进行选择。
Using
fsel
by itself can often result in incorrect results for exceptional values like NaN and Inf. You'll have to consider the results for each comparison carefully.Integer select has been implemented in at least two variants of PowerPC.
IBM has the
selii
,selir
,selri
,selrr
instructions in their AS/400 systems. These can select between a register or a signed 5-bit immediate for each source. The decision is based on an AS/400-specific register.Motorola/Freescale has the "isel APU" found in the e200 and e500 series (and possibly others). These use a regular condition register bit, but can only select from register sources.