[Bug target/53987] [SH] Unnecessary zero-extension before cmp/eq

olegendo at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 29 21:58:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53987

--- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> ---
As of rev 204180 (4.9) this problem still exists.
As far as I understand, the actual root of the problem is that the 'unsigned
char' mem loads into regs are neither sign nor zero extended.  So combine sees
the following:

(insn 11 6 12 2 (set (reg:QI 169 [ *a_3(D) ])
        (mem:QI (reg:SI 4 r4 [ a ]) [0 *a_3(D)+0 S1 A8])) {*movqi}
     (expr_list:REG_DEAD (reg:SI 4 r4 [ a ])
        (nil)))
(insn 12 11 13 2 (set (reg:SI 168 [ *a_3(D)+-3 ])
        (zero_extend:SI (reg:QI 169 [ *a_3(D) ]))) {*zero_extendqisi2_compact}
     (expr_list:REG_DEAD (reg:QI 169 [ *a_3(D) ])
        (nil)))
(insn 13 12 14 2 (set (reg:QI 171 [ *b_5(D) ])
        (mem:QI (reg:SI 5 r5 [ b ]) [0 *b_5(D)+0 S1 A8])) {*movqi}
     (expr_list:REG_DEAD (reg:SI 5 r5 [ b ])
        (nil)))
(insn 14 13 15 2 (set (reg:SI 170 [ *b_5(D)+-3 ])
        (zero_extend:SI (reg:QI 171 [ *b_5(D) ]))) {*zero_extendqisi2_compact}
     (expr_list:REG_DEAD (reg:QI 171 [ *b_5(D) ])
        (nil)))
(insn 15 14 16 2 (set (reg:SI 147 t)
        (eq:SI (reg:SI 168 [ *a_3(D)+-3 ])
            (reg:SI 170 [ *b_5(D)+-3 ]))) {cmpeqsi_t}
     (expr_list:REG_DEAD (reg:SI 170 [ *b_5(D)+-3 ])
        (expr_list:REG_DEAD (reg:SI 168 [ *a_3(D)+-3 ])
            (nil))))

On the other hand, signed char mem loads are expanded as sign extending.
Since LOAD_EXTEND_OP tells that any mem loads but SImode are sign extending,
one could expect that all mem loads will be automatically expanded as such,
which is not the case.



More information about the Gcc-bugs mailing list