http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48774
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-02
13:58:28 UTC ---
This looks like a target bug to me
in *.postreload we have:
(insn 615 177 616 32 (set (reg:CCC 17 flags)
(compare:CCC (zero_extract:DI (reg:DI 5 di [orig:129 prephitmp.8 ]
[129])
(const_int 1 [0x1])
(const_int 1 [0x1]))
(const_int 0 [0]))) pr48774-6.c:23 377 {*testqi_ext_3_rex64}
(nil))
(jump_insn 616 615 184 32 (set (pc)
(if_then_else (ne (reg:CCC 17 flags)
(const_int 0 [0]))
(label_ref 214)
(pc))) pr48774-6.c:23 589 {*jcc_1}
(expr_list:REG_BR_PROB (const_int 5000 [0x1388])
(nil))
which comes from jcc_bt* splitter, where the second const1_rtx still was a
register at the time of the split, but IRA materialized it into a constant.
The CCC mode is fine for bt insn. Unfortunately split2 pass splits this into:
(insn 626 177 616 32 (set (reg:CCC 17 flags)
(compare:CCC (and:QI (reg:QI 5 di [orig:129 prephitmp.8 ] [129])
(const_int 2 [0x2]))
(const_int 0 [0]))) pr48774-6.c:23 369 {*testqi_1_maybe_si}
(nil))
(jump_insn 616 626 184 32 (set (pc)
(if_then_else (ne (reg:CCC 17 flags)
(const_int 0 [0]))
(label_ref 214)
(pc))) pr48774-6.c:23 589 {*jcc_1}
(expr_list:REG_BR_PROB (const_int 5000 [0x1388])
(nil))
-> 214)
which is already incorrect, if we want to replace bt-ish test, we'd need to
update the mode to CCmode or similar and update the user(s).
The generated assembly then has:
andl $2, %edi
jnc .L21
whereas it should have been either
btl $1, %edi
jnc .L21
or
andl $2, %edi
je .L21