https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106654
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- Note my main dislike is because the former is essentially <if we run here, 'cond' must have hold> if (0) { if (!cond) __builtin_unreachable (); } <something where 'cond' should hold> that is, the assumption itself, not only its condition computation (and side-effects) are thrown away. With cond = .IFN_ASSUME (outlined_cond_computer, args...); if (!cond) __builtin_unreachable (); or as Jakub prefers with implicit unreachable, the side-effects we want to elide are in 'outlined_cond_computer' and we can later "optimize" the .IFN_ASSUME call to compute true. For ranger the difficulty in the latter form is that there will be assertions on 'args...', variables at the call site, but what they are is specified by outlined_cond_computer returning true. Consider _bool outlined_cond_computer (int i, int j) { return i_1(D) == j_2(D); } from [[assume(i == j)]]; we'd then have .IFN_ASSUME (cond_fn, i_2, j_5); and just like IPA does, we'd have to "connect" relations/ranges produced by outlined_cond_computer via argument positions. I think we can easily funnel in argument ranges from the caller and thus possibly compute outlined_cond_computer outgoing ranges for the arguments (only those are interesting!) on the "true" return edge. Complication is the IL is in another function, set_cfun is a bit expensive but in theory most things could be formulated in a way to not require 'cfun' be set "correctly". On the C++ frontend side I'd simply handle [[assume(expr)]] as if 'expr' were in a lambda -> bool with everything captured by value.