https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116776
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2024-09-19 Ever confirmed|0 |1 --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- It's different, only the outermost condition load is hoisted (the inner ones could trap!) and unswitching would only iteratively hoist (it unswitches on the x->dims[1] condition), it does not consider unswitching on a whole sub-CFG representing a not short-circuited && condition. An intermediate step would be to transform this into if (shouldthischange(x, 0, 0) && shouldthischange(y, 0, 0) && shouldthischange(z, 0, 0)) flag = 1; else flag = 0; for (...) if (flag) ... loop invariant motion can hoist some conditions but in reality it looks at invariant PHIs, hoisting them as ?: and rely on CFG cleanup to elide empty ifs. In principle LIM can compute all invariant info but of course it doesn't implement hoisting a sub-CFG or re-materializing a sub-CFG to compute a condition argument.