[LLVMdev] [RFC] Extend LLVM IR to express "fast-math" at a per-instruction level

Krzysztof Parzyszek kparzysz at codeaurora.org
Tue Oct 30 06:48:40 PDT 2012


On 10/29/2012 10:22 PM, Michael Ilseman wrote:
>
>
> The goal is not necessarily to un-define Inf/NaN, but to opt-in to unsafe optimizations that would otherwise not be allowed to be applied, e.g. x*0==>0. There may be examples where these optimizations produce arbitrary results as though those constructs were absent in meaning, but that doesn't make Inf/NaN constants completely undefined in general. The "when convenient" wording is already a little vague/permissive, and could be re-worded to state that Values are assumed to not be Inf/NaN when convenient, but Constants may be honored.

The problem may be in that, in general, it may not be clear whether a 
given constant appears in the simplifiable computation or not.  For 
example, if we have "x > y", and we manage to constant propagate "inf" 
in place of "x", we end up with "inf > y", which you suggested be folded 
to "true".  However, as our constant propagation algorithm becomes more 
aggressive, it may be capable of propagating a constant into "y", which 
may also turn out to be "inf".  This way we end up with "inf > inf".  In 
such case, again we follow the rule of respecting constants, but now we 
generate "false".

Once we assume that there are no inifinities, and an infinity is 
actually present, the results are unpredictable.

-Krzysztof

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the llvm-dev mailing list