https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91812

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so while the comment says to exclude volatile the code never checked for
that:

            /* We cannot replace a load that may throw or is volatile.  */
            && !stmt_can_throw_internal (cfun, use_stmt)))

the situation is also more subtle as generally replacing a volatile load is
OK but only when the number of times it is executed does not change.
Currently we're set up for (post-)dominator checks but with those there's
no guarantee of this.  Instead we'd have to use loop information and look
out for irreducible regions.  Not worth the trouble, but it will make
code doing std::max (volatile, ..) less optimal (and I do remember C++
code ticking const volatile on all incoming parameters just to avoid
warnings when passing in volatile qualified pointers...).

Reply via email to