[PATCH] D14071: [FPEnv Core 06/14] Do not fold constants on reading in IR asm/bitcode

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 26 09:29:38 PDT 2015


majnemer added a comment.

In http://reviews.llvm.org/D14071#275272, @sdmitrouk wrote:

> In http://reviews.llvm.org/D14071#275229, @majnemer wrote:
>
> > Why are we making this assumption?  It seems strange to assume that all constant expressions infer KeepExceptions and KeepRounding.
>
>
> Constant expressions do not have fast-math flags, the sole purpose of setting them here is to prevent any kind of folding. As there is no way to specify flags, assuming FPEnv access should work for all cases.


That sounds like an oversight.  We have overflow flags (`nsw`/`nuw`) for integer math.

> I don't think anything should be folded in any reader or writer. Without this patch `<input> != write(read(<input>))` for constant expressions, which is a problem in case of preserving side-effects, but is also an odd behaviour in general.

> 

> In http://reviews.llvm.org/D14071#275229, @majnemer wrote:

> 

> > Also, shouldn't we be folding these to SNaN if KeepExceptions is true?

> 

> 

> If you're talking about examples in test, then probably not, they return infinity or a number, SNaN is not equivalent to those values.


I am not, I am thinking about the general case.  It sounds reasonable to transform floating-point divide by zero into SNaN when fp-exceptions are enabled.


Repository:
  rL LLVM

http://reviews.llvm.org/D14071





More information about the llvm-commits mailing list