英文:
Rationale for default NaN is never returned from FABS, FMAX*, FMIN*, and FNEG instructions
问题
“DN,位 [25]
默认 NaN 用于 NaN 传播。
0b0 NaN 操作数传播到浮点操作的输出。
0b1 任何涉及一个或多个 NaN 的操作都返回默认 NaN。
此位对 FABS、FMAX*、FMIN* 和 FNEG 指令的输出没有影响,
并且这些指令的结果永远不会返回默认 NaN。”
一个简单的问题:强调文本的理由是什么?
从这些指令返回默认 NaN 的障碍是什么?
英文:
Arm Architecture Reference Manual for A-profile architecture (issue I.a) (emphases added):
> DN, bit [25]
>
> Default NaN use for NaN propagation.
>
> 0b0 NaN operands propagate through to the output of a floating-point operation.
>
> 0b1 Any operation involving one or more NaNs returns the Default NaN.
>
> This bit has no effect on the output of FABS, FMAX*, FMIN*, and FNEG instructions,
> and a default NaN is never returned as a result of these instructions.
A simple question: what is the rationale for the emphasized text?
What are the obstacles to return a default NaN from these instructions?
答案1
得分: 2
FNEG
通常有一个非常简单的实现方式:只需翻转符号位。为了提供"默认NaN"行为,它必须包括一个NaN测试以触发特殊处理,这可能会降低效率。大多数其他指令已经需要对NaN进行特殊处理以获得正确的数学结果,在这种情况下,更改处理方式时DN被设置不会太糟糕。
FABS
类似,因为它可以通过无条件清除符号位来实现。
对于FMAX/FMIN
,它们通常被定义为具有类似于x > y ? x : y
的行为,其中结果始终是两个输入中的一个,这一特性被认为是相当基本的。将NaN结果替换为默认NaN会破坏这一特性。
英文:
FNEG
normally has a very simple implementation: just flip the sign bit. In order to provide "default NaN" behavior, it would have to include a test for NaN to trigger special handling, making it possibly less efficient. Most other instructions already need special handling for NaN to get correct mathematical results, in which case it isn't so bad to change that handling when DN is set.
FABS
is similar, in that it can be implemented by unconditionally clearing the sign bit.
For FMAX/FMIN
, they are usually defined to have behavior like x > y ? x : y
, where the result is always one of the two inputs, and this property is considered rather fundamental. Replacing a NaN result with a default NaN would break it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论