Hello, I have a question about the constant folding for fdiv instructions. For the instruction "fdiv double 0.0, 0.0", the folded result is inf. I think this should be nan. Can anyone tell me why it is not nan? Thanks. Leo _________________________________________________________________ Exercise your brain! Try Flexicon. http://games.msn.com/en/flexicon/default.htm?icid=flexicon_hmemailtaglinemarch07
On Thu, 2007-03-22 at 15:50 -0700, leo han wrote:> Hello, I have a question about the constant folding for fdiv instructions. > For the instruction "fdiv double 0.0, 0.0", the folded result is inf. I > think this should be nan. Can anyone tell me why it is not nan?I think the specification says that it is "undefined" so any value will do. inf is just as undefined as nan. Reid.> Thanks. > > Leo > > _________________________________________________________________ > Exercise your brain! Try Flexicon. > http://games.msn.com/en/flexicon/default.htm?icid=flexicon_hmemailtaglinemarch07 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On 3/22/07, Reid Spencer <rspencer at reidspencer.com> wrote:> On Thu, 2007-03-22 at 15:50 -0700, leo han wrote: > > Hello, I have a question about the constant folding for fdiv instructions. > > For the instruction "fdiv double 0.0, 0.0", the folded result is inf. I > > think this should be nan. Can anyone tell me why it is not nan? > > I think the specification says that it is "undefined" so any value will > do. inf is just as undefined as nan.I seem to recall that gcc's interpretation of undefined in this situation is also inf. Andrew
Reid Spencer wrote:> On Thu, 2007-03-22 at 15:50 -0700, leo han wrote: > >> Hello, I have a question about the constant folding for fdiv instructions. >> For the instruction "fdiv double 0.0, 0.0", the folded result is inf. I >> think this should be nan. Can anyone tell me why it is not nan? >> > > I think the specification says that it is "undefined" so any value will > do. inf is just as undefined as nan. > > Reid.In IEEE Std 754-1985, subclause 7.2- Division by Zero, it says: /"If the divisor is zero and the dividend is a finite nonzero number, then the division by zero shall be signaled. The result, when no trap occurs, shall be a correctly signed (infinity symbol)(6.3)." /So LLVM is correct (assuming it handles signs correctly). -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070322/36519826/attachment.html>