Constrained intrinsics model the interaction with floating point
environment as side effect. It creates problems if some transformation
replaces an intrinsic call and leaves the call dangling. As the call has
side effect, it cannot be removed by DCE. On the other hand, in many
cases the side effect is absent or may be ignored and it is safe to
remove such call.
In particular, such problem exists in constant folding. Intrinsic call
cannot be modified inside constant evaluator so it must be made somewhere
in the transformation pass. There are several passes that could call
constant evaluator, putting cleanup code to each of them does not look
like a flexible solution. Instead, this patch introduces a pass that makes
the cleanup in one place. The pass is executed late in a pipeline, when
all relevant replacements have already done.
Although this change is made for solving constant evaluation problems,
removing floating-point operation side effect is useful in other cases
also. For example, if FP exceptions are ignored but rounding mode is
non-default, side effect may be removed in many cases, it can produce
faster code. The new pass could be used for this task also, but in this
case it must be executed also somewhere earlier in pipeline.
Why is this not getting removed as well?