Open
Description
Bugzilla Link | 8100 |
Version | trunk |
OS | Linux |
Reporter | LLVM Bugzilla Contributor |
CC | @andykaylor,@delcypher,@DimitryAndric,@emaste,@ecnelises,@ismail,@kcc,@sunfishcode,@zygoloid,@rnk,@rotateright,@tavianator,@tydeman,@vinc17fr,@vadz,@yabinc,@yuanfang-chen,@zamazan4ik |
Extended Description
Hello,
consider this code:
#include <fenv.h>
#include <assert.h>
int main(){
double a=1.1;
double b=10.1;
fesetround(FE_UPWARD);
assert(-((-a)b)!=ab);
}
Excessive optimization will remove the double negation. gcc has option -frounding-math to help with this. Intel's -fp-model strict is not quite as good (it fails for this example) but it helps (for instance it lets the code work if I write 1.1 and 10.1 instead of a and b in the assertion). With llvm-gcc or clang, this always fails at -O1.
A similar option for llvm would be very welcome, there are applications where rounding in the appropriate direction is crucial (precision and speed come far behind).