https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67285
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- There are two issues here - one is side-effects (virtual definition) and one is dependences (virtual uses). The first one you hit with -fmath-errno, the second you hit with -frounding-math. On GENERIC there can be nothing "inbetween" components of the matched expression so things are usually fine. On GIMPLE there can be random statements inbetween the statements composing the matched expression. Like _1 = pow (x, 2) fesetround(); _2 = _1 / x; we may not move pow () across fesetround () with -frounding-math, thus we may not generate the expression replacement at the point of the _2 definition. The actual ICE is about our failure to keep the virtual operand SSA form up-to-date in fold_stmt. As we generally do not want to do IL walks to find a suitable VUSE/DEF we can use for that (apart from looking at the current statement) we generally have to fail doing the expression replacement. Implementation-wise the easiest is to "fail" when we are trying to generate a builtin function call which is not CONST. That doesn't avoid all questionable transforms but at least should avoid the ICEs due to non-up-to-date virtual operand form. There are cases we could relax (like replacing a call with another call), but let's do that separately. Note that this will require -fno-math-errno for any late transforms regarding to math builtins.