On Thu, 2024-05-16 at 10:35 +0200, Richard Biener wrote: > On Fri, Apr 5, 2024 at 8:14 PM Andrew Pinski <pins...@gmail.com> wrote: > > > > On Fri, Apr 5, 2024 at 5:28 AM Manolis Tsamis <manolis.tsa...@vrull.eu> > > wrote: > > > > > > If we consider code like: > > > > > > if (bar1 == x) > > > return foo(); > > > if (bar2 != y) > > > return foo(); > > > return 0; > > > > > > We would like the ifcombine pass to convert this to: > > > > > > if (bar1 == x || bar2 != y) > > > return foo(); > > > return 0; > > > > > > The ifcombine pass can handle this transformation but it is ran very > > > early and > > > it misses the opportunity because there are two seperate blocks for foo(). > > > The pre pass is good at removing duplicate code and blocks and due to that > > > running ifcombine again after it can increase the number of successful > > > conversions. > > > > I do think we should have something similar to re-running > > ssa-ifcombine but I think it should be much later, like after the loop > > optimizations are done. > > Maybe just a simplified version of it (that does the combining and not > > the optimizations part) included in isel or pass_optimize_widening_mul > > (which itself should most likely become part of isel or renamed since > > it handles more than just widening multiply these days). > > I've long wished we had a (late?) pass that can also undo if-conversion > (basically do what RTL expansion would later do). Maybe > gimple-predicate-analysis.cc (what's used by uninit analysis) can > represent mixed CFG + if-converted conditions so we can optimize > it and code-gen the condition in a more optimal manner much like > we have if-to-switch, switch-conversion and switch-expansion. > > That said, I agree that re-running ifcombine should be later. And there's > still the old task of splitting tail-merging from PRE (and possibly making > it more effective).
Sorry to butt in, but it might be little bit relevant and caught my attention. I've got this SH patch sitting around https://gcc.gnu.org/bugzilla/attachment.cgi?id=55543 The idea is basically to run an additional loop pass after combine and split1. The main purpose is to hoist constant loads out of loops. Such constant loads might be formed (in this particular case) during combine transformations. The patch adds a new file gcc/config/sh/sh_loop.cc, which has some boiler- plate code copy pasted from other places to get the loop pass setup and going. Any thoughts on this way of doing it? Best regards, Oleg Endo