i need to check if an overflow of an floating-point arithmetic operation occured.Currently I'm doing something like this (for addition):(LHS > 0 && RHS > 0 && sum <= 0) || (LHS < 0 && RHS < 0 && sum >= 0)
Two things:
1) Have you tried adding 2 float-max values together to see what you
get? It's not a negative (on most platforms, at least). IEEE
floating-point has "infinities".
2) That method doesn't even work for integers, since overflow in
signed addition is undefined, and compilers will, correctly, remove
the check as impossible.
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
- If you're talking about compile-time arithmetic, you should be using the APFloat library, which figures this out for you.
I don't think so; we probably don't select those instructions at all. I'm not sure what the best way to select them would be, to be honest; maybe a processor-specific intrinsic. I'd suggest filing a bug.
John.