https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91374
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Version|tree-ssa |10.0 Keywords| |missed-optimization Last reconfirmed| |2019-08-07 Component|tree-optimization |ipa CC| |jamborm at gcc dot gnu.org, | |marxin at gcc dot gnu.org Ever confirmed|0 |1 Severity|normal |enhancement --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- So you ask for main to be converted to if (idx == 0) foo_32_16 (); else /* idx == 1 */ foo_16_8 (); correct? It shoulds like an interesting idea for an IPA-CP cloning opportunity. But I wonder how much real-world testcases exists that are not benchmarks ;) One could tell by implementing the analysis into the param analysis stage (look for defs that are loads from a constant initialized entity, possibly multiple of them and (some of them) reusing the same memory index). A related thing would be to value-profile the indexes since when the array doesn't only contain two values it isn't feasible to clone for all possible values.