https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121383
--- Comment #3 from Tamar Christina <tnfchris at gcc dot gnu.org> --- (In reply to Richard Biener from comment #2) > if-conversion does nothing to loops with multiple exits. One could think to > sub-divide its work, but in this case there's a lack of PHIs and the > expected if-conversion is on control dependences rather than data > dependences. > > I would rather see this as an opportunity to look how to handle such cases > in the vectorizer itself? I had thought about that as well and that was my initial approach, however I figured this particular case fits better in ifcvt. I wanted ifcvt to split int foo () { for (int i = 0; i < N; i++) { if (a[i] > b[i] && a[i] > c[i]) return 1; } return 0; } into essentially int foo () { for (int i = 0; i < N; i++) { bool v = a[i] > b[i] && a[i] > c[i]; if (v != 0) return 1; } return 0; } which because a, b and c all need to be speculated should be safe to do, and I had a small prototype where it mostly worked. We *could* do it in the vectorizer, but that means that every statement in the second block needs to be predicated. So it'll only work for masked targets whereas I think the original loop should work for non-masked ones too. But will give the in-vectorizer one a try. I'll limit it only to if blocks for now rather than if-then-else as well.