GCC's man page states that -funsafe-math-optimizations
allows for optimizations that "(a) assume that arguments and results are valid and (b) may violate IEEE or ANSI standards", but that's not very precise, is it?
What could an "invalid" argument be in this case? NaNs? Infinites? Subnormals? Negative numbers to sqrt()
?
How far are results allowed to deviate from IEEE or ANSI standards? Is it "merely" stuff like operation associativity and ordering, or might it include eg. true comparisons with NaNs or incorrect comparisons with infinites? Could a stored variable be re-rounded after already being used (such that, for variables x
and y
, (x == y) + (x == y)
could evaluate to 1)? Could isinf()
/isnan()
stop working?
Do the GCC devs follow any particular system or discipline with regards to such questions, or could the answer differ wildly from version to version?
There are two distinct types of optimization algorithms widely used today. (a) Deterministic Algorithms. They use specific rules for moving one solution to other. These algorithms are in use to suite some times and have been successfully applied for many engineering design problems.
What is optimization? Optimization technique is a powerful tool to obtain the desired design parameters and. best set of operating conditions .This would guide the experimental work and reduce. the risk and cost of design and operating.
Every optimization problem has three components: an objective function, decision variables, and constraints.
According to gcc.gnu.org (my bold):
This mode enables optimizations that allow arbitrary reassociations and transformations with no accuracy guarantees. It also does not try to preserve the sign of zeros.
That includes your mention of associative reordering, as well as "Built-in functions [which] have names such as __builtin_sqrt" being applied when they "may have less precision or be restricted to a smaller domain"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With