Intention of NoContraction


Is the intention of the NoContraction decoration to never fuse any two operations or to never fuse any two operations that would otherwise alter the result?

From the spec:

Apply to an arithmetic instruction to indicate the
operation cannot be combined with another
instruction to form a single operation. For
example, if applied to an OpFMul, that multiply
can’t be combined with an addition to yield a
fused multiply-add operation. Furthermore, such
operations are not allowed to reassociate; e.g.,
add(a + add(b+c)) cannot be transformed to
add(add(a+b) + c).

I read this as ‘never fuse any two operations, period’ but we’d like to be sure.



I would use the as-if rule: If fusing the operations behaves as if the operations were not fused, then it doesn’t really matter if you fused them. The NoContraction rule is used to make sure rounding, overflow, and other corner case behaviours are consistent and as predictable as possible.