On 8/26/24 1:15 PM, Georg-Johann Lay wrote:


What the avr-ifelse pass does is try to replace 2 cbranch insns with
one compare insn and two branches.  It runs after reload and just prior
to .split2 (split_after_reload).  It must run after reload because
REG_CC comes into existence in .split2.  For example, the last case
belongs to transforming

    if (x == (unsigned) -1) goto A;
    if (x == (unsigned) -2) goto B;

to

    REG_CC = x compare (unsigned) -2;
    if (REG_CC >  0) goto A;
    if (REG_CC == 0) goto B;
Hmm. I'd envisioned doing this in gimple, but as your example shows, it's not suitable for gimple (it's an extra expression evaluation).


(As an aside, this will be transformed further down the line to

    REG_CC = x compare (unsigned) -2;
    if (REG_CC == 0) goto B;
    if (REG_CC >= 0) goto A;

in order to avoid GTU.)

None of the code really looks AVR specific, so is there a good reason why we're not doing this in one of the target independent passes?

That target-independent pass would be compare-elim, which avr does
not use.  Some of the reasons why not using compare-elim I tried to
get across in the review for PR115830:
It feels like it'd fit in RTL jump optimizations, well outside compare-elim. Though that may still be too high level. So yea, let's keep it AVR specific.


Jeff

Reply via email to