[LLVMdev] LLVM floating point rounding modes

Rotem, Nadav nadav.rotem at intel.com
Sat Jul 9 11:21:41 PDT 2011


The LLVM IR does not specify the rounding mode. On X86/SSE, the rounding mode of FP operations is controlled by the mxcsr register. You can use the set/get mxcsr intrinsic to control it (declaration below). However, there is an old bug (#6393) which makes the LLVM scheduler schedule fp instructions past this call. To get around this bug you will have to place the 'stmxcsr' call in an external function, thus forcing a full barrier. 


Bug report:


declare void @llvm.x86.sse.stmxcsr(i32*) nounwind
declare void @llvm.x86.sse.ldmxcsr(i32*) nounwind

-----Original Message-----
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Steven Obua
Sent: Saturday, July 09, 2011 20:57
To: llvmdev at cs.uiuc.edu
Subject: [LLVMdev] LLVM floating point rounding modes


I am not sure if this is the right mailing list to ask my question, if not, please refer me to the proper one.

Is there any support for rounding modes in LLVM floating point? I looked in the assembler reference manual, and it doesn't seem so. I am thinking about choosing LLVM as one of the backends for my programming language Babel-17 (www.babel-17.com). Babel-17 features interval arithmetic, which can be implemented sub-optimally without proper rounding modes, but it would be so much better and faster if rounding modes were provided. Are there any plans of introducing this in LLVM or of making any IEEE guarantees concerning floating point arithmetic?


LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

More information about the llvm-dev mailing list