09-173 To: J3 From: Van Snyder Subject: Clarify effect of "as if" in execution sequence Date: 2009 March 27 References: 09-007r1 1. Discussion The "as if" specification in 2.3.5p2 [33:11-12] allows processors some freedom and puts some nonobvious restrictions on them. This could be illuminated by adding some notes. 2. Edits [33:21+ 2.3.5p2+]------------------------------------------------------- Editor: Add NOTE 2.6a "NOTE 2.6a Processors have some latitude for inter-statement optimization, including common subexpression elimination and carrying intermediate results in high-precision registers, so long as the "as if" requirement of the execution sequence specification is maintained." [151:40+ 7.1.9.3p4+]---------------------------------------------------- Editor: Add NOTE 7.31a at the end of subclause 7.1.9.3: "NOTE 7.31a Processors have some latitude to use a representation for the result of an operation that is different from the representation of a variable having the same type and kind as that result, so long as the "as if" requirement of the execution sequence specification (2.3.5) is maintained." [408:28+ 14.4p4+]------------------------------------------------------- Editor: Add NOTE 14.4a between the end of 14.4p4 and NOTE 14.5: "NOTE 14.4a If a processor uses a representation for the result of an operation (7.1.9.3) that is different from the representation of a variable having the same type and kind as that result, and that result is later converted to a different representation (for example, to be stored from a register into memory), changing the IEEE rounding mode between those two events could violate the "as if" requirement of the execution sequence specification (2.3.5). For example, if a subexpression is evaluated with upward rounding, with the intent that the computed result is not less than the mathematical result, and the processor represents that result using higher precision than is implied by the kind specified by 7.1.9.3, and that result is later rounded to that kind with downward rounding, the computed result might be less than the mathematical result."