https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105715

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So I guess the trick might be to notice that ...

;; _2 = a_1(D) < b_10(D);

(insn 12 11 13 (set (reg:CCGC 17 flags)
        (compare:CCGC (reg/v:DI 86 [ a ])
            (reg/v:DI 87 [ b ]))) -1
     (nil))

(insn 13 12 14 (set (reg:QI 92)
        (lt:QI (reg:CCGC 17 flags)
            (const_int 0 [0]))) -1
     (nil))

(insn 14 13 0 (set (reg:QI 82 [ _2 ])
        (reg:QI 92)) -1
     (nil))

... we expand to CCGCmode here ...

_3 replace with --> _3 = _2 ? c_4(D) : d_5(D);
 ;; *p_9(D) = _3;

(insn 15 14 16 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg:QI 82 [ _2 ])
            (const_int 0 [0]))) "t2.c":12:7 -1
     (nil))

(insn 16 15 17 (set (reg:DI 93)
        (if_then_else:DI (ne (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (reg/v:DI 88 [ c ])
            (reg/v:DI 89 [ d ]))) "t2.c":12:7 -1
     (nil))

... and thus want to use a CCGCmode based compare here as well?  We can
of course force-forward ("un-CSE") the condition during RTL expansion.
But the question would be what's the best approach to deal with the
situation so that followup RTL passes have a chance to optimize the
redundant compares?

Reply via email to