https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115629
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2024-06-25 Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- I think the transform is profitable for scalar for all cases as well. Now, if-conversion records BB predicates and uses those to predicate stmts/PHIs, I'm not sure how to go optimize it on that level. It's more a CFG transform of a if (A) x; else { if (B) x; else y; } to if (A || B) x; else y; with the downside that in this case evaluating 'B' has side-effects (memory dereference which can trap). Due to the trapping this needs to be somehow done in if-conversion where you also need to determine that x == x' (both copies of x evaluate to the same code). Some scalar GIMPLE opt could have de-duplicated the BB with 'x' (tail-merging to the rescue? it considers the cands but somehow doesn't merge - I think the PHI node isn't supported).