Sergey Dmitrouk
2014-Sep-19 15:12 UTC
[LLVMdev] More careful treatment of floating point exceptions
Hi, I'd like to make code emitted by LLVM that includes floating point operations which raise FP exceptions behave closer to what is defined by IEEE754 standard. I'm not going to "fix everything", just incorrect behaviour I faced so far. Most of troubles regarding FP exceptions are caused by optimizations, so there should be a flag to disable/block them if one wants to get better code in a sense of its IEEE754 conformance. I couldn't find an existing flag for this and would like to introduce one. I guess it should be added to llvm::TargetOptions (e.g. "IEEE754FPE"), then -std=c99 or separate option could enable it from front-end (Clang in this case). I'm doing this for ARM platform and the flag should be reachable from all these places in LLVM: - lib/Analysis/ValueTracking.cpp - lib/CodeGen/SelectionDAG/SelectionDAG.cpp - lib/IR/ConstantFold.cpp - lib/Target/ARM/ARMFastISel.cpp - lib/Target/ARM/ARMISelLowering.cpp - lib/Target/ARM/ARMInstrVFP.td (through predicates) - lib/Target/ARM/ARMRegisterInfo.td (through predicates) and in Clang: - lib/AST/ExprConstant.cpp Did I get it right and there is no such flag so far? Does what I'm suggesting sounds reasonable? Thanks, Sergey
Sanjay Patel
2014-Sep-19 19:01 UTC
[LLVMdev] More careful treatment of floating point exceptions
Hi Sergey - Does this solve part of the problem? http://llvm.org/viewvc/llvm-project?view=revision&revision=215222 On Fri, Sep 19, 2014 at 9:12 AM, Sergey Dmitrouk <sdmitrouk at accesssoftek.com> wrote:> Hi, > > I'd like to make code emitted by LLVM that includes floating point > operations which raise FP exceptions behave closer to what is defined by > IEEE754 standard. I'm not going to "fix everything", just incorrect > behaviour I faced so far. > > Most of troubles regarding FP exceptions are caused by optimizations, so > there should be a flag to disable/block them if one wants to get better > code in a sense of its IEEE754 conformance. I couldn't find an existing > flag for this and would like to introduce one. I guess it should be > added to llvm::TargetOptions (e.g. "IEEE754FPE"), then -std=c99 or > separate option could enable it from front-end (Clang in this case). > > I'm doing this for ARM platform and the flag should be reachable from > all these places in LLVM: > > - lib/Analysis/ValueTracking.cpp > - lib/CodeGen/SelectionDAG/SelectionDAG.cpp > - lib/IR/ConstantFold.cpp > - lib/Target/ARM/ARMFastISel.cpp > - lib/Target/ARM/ARMISelLowering.cpp > - lib/Target/ARM/ARMInstrVFP.td (through predicates) > - lib/Target/ARM/ARMRegisterInfo.td (through predicates) > > and in Clang: > > - lib/AST/ExprConstant.cpp > > Did I get it right and there is no such flag so far? Does what I'm > suggesting sounds reasonable? > > Thanks, > Sergey > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140919/929089c7/attachment.html>
Sergey Dmitrouk
2014-Sep-19 19:59 UTC
[LLVMdev] More careful treatment of floating point exceptions
Hi Sanjay, Thanks, I saw this flag and it's definitely should be considered, but it appeared to me to be static characteristic of target platform. I'm not sure how appropriate it would be to change its value from a front-end. It says "Has", while optional flag would rather say "Uses" meaning that implementation cares about floating point exceptions. Regards, Sergey On Fri, Sep 19, 2014 at 12:01:07PM -0700, Sanjay Patel wrote:> Hi Sergey - > > Does this solve part of the problem? > http://llvm.org/viewvc/llvm-project?view=revision&revision=215222 > On Fri, Sep 19, 2014 at 9:12 AM, Sergey Dmitrouk > <sdmitrouk at accesssoftek.com> wrote: > > Hi, > > I'd like to make code emitted by LLVM that includes floating point > operations which raise FP exceptions behave closer to what is defined by > IEEE754 standard.A I'm not going to "fix everything", just incorrect > behaviour I faced so far. > > Most of troubles regarding FP exceptions are caused by optimizations, so > there should be a flag to disable/block them if one wants to get better > code in a sense of its IEEE754 conformance.A I couldn't find an > existing > flag for this and would like to introduce one.A I guess it should be > added to llvm::TargetOptions (e.g. "IEEE754FPE"), then -std=c99 or > separate option could enable it from front-end (Clang in this case). > > I'm doing this for ARM platform and the flag should be reachable from > all these places in LLVM: > > A - lib/Analysis/ValueTracking.cpp > A - lib/CodeGen/SelectionDAG/SelectionDAG.cpp > A - lib/IR/ConstantFold.cpp > A - lib/Target/ARM/ARMFastISel.cpp > A - lib/Target/ARM/ARMISelLowering.cpp > A - lib/Target/ARM/ARMInstrVFP.td (through predicates) > A - lib/Target/ARM/ARMRegisterInfo.td (through predicates) > > and in Clang: > > A - lib/AST/ExprConstant.cpp > > Did I get it right and there is no such flag so far?A Does what I'm > suggesting sounds reasonable? > > Thanks, > Sergey > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.eduA A A A A http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reasonably Related Threads
- [LLVMdev] More careful treatment of floating point exceptions
- [LLVMdev] Proposal: Add a target lowering hook to state that target supports floating point exception behavior.
- [LLVMdev] Proposal: Add a target lowering hook to state that target supports floating point exception behavior.
- [LLVMdev] Soft floating point support
- Bug or expected behavior of APFloat class?