Hi,
I think the rtl dump in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64916
is not jump2 phase rtl dump.
Because jump2 is after ira, the register number should be hardware
register number.
the jump2 rtl dump should as follow
...
31: NOTE_INSN_BASIC_BLOCK 5
32: [r6:SI]=r4:SI
REG_DEAD r6:SI
REG_DEAD r4:SI
33: [r5:SI]=r0:SI
REG_DEAD r5:SI
REG_DEAD r0:SI
7: r0:SI=0
REG_EQUAL 0
85: use r0:SI
86:
{return;sp:SI=sp:SI+0x18;r3:SI=[sp:SI];r4:SI=[sp:SI+0x4];r5:SI=[sp:SI+0x8];r6:SI=[sp:SI+0xc];r7:SI=[sp:SI+0x10];pc:SI=[sp:SI+0x14];}
REG_UNUSED pc:SI
REG_UNUSED r3:SI
REG_CFA_RESTORE r7:SI
REG_CFA_RESTORE r6:SI
REG_CFA_RESTORE r5:SI
REG_CFA_RESTORE r4:SI
REG_CFA_RESTORE r3:SI
77: barrier
46: L46:
45: NOTE_INSN_BASIC_BLOCK 6
8: r0:SI=r4:SI
REG_DEAD r4:SI
REG_EQUAL 0xffffffffffffffff
87: use r0:SI
88:
{return;sp:SI=sp:SI+0x18;r3:SI=[sp:SI];r4:SI=[sp:SI+0x4];r5:SI=[sp:SI+0x8];r6:SI=[sp:SI+0xc];r7:SI=[sp:SI+0x10];pc:SI=[sp:SI+0x14];}
REG_UNUSED pc:SI
REG_UNUSED r3:SI
REG_CFA_RESTORE r7:SI
REG_CFA_RESTORE r6:SI
REG_CFA_RESTORE r5:SI
REG_CFA_RESTORE r4:SI
REG_CFA_RESTORE r3:SI
79: barrier
54: L54:
53: NOTE_INSN_BASIC_BLOCK 7
9: r0:SI=0xffffffffffffffff <== lost REG_EQUAL after patch
34: L34:
35: NOTE_INSN_BASIC_BLOCK 8
41: use r0:SI
90:
{return;sp:SI=sp:SI+0x18;r3:SI=[sp:SI];r4:SI=[sp:SI+0x4];r5:SI=[sp:SI+0x8];r6:SI=[sp:SI+0xc];r7:SI=[sp:SI+0x10];pc:SI=[sp:SI+0x14];}
REG_UNUSED pc:SI
REG_UNUSED r3:SI
REG_CFA_RESTORE r7:SI
REG_CFA_RESTORE r6:SI
REG_CFA_RESTORE r5:SI
REG_CFA_RESTORE r4:SI
REG_CFA_RESTORE r3:SI
89: barrier
try_forward_edges(remove basic block 6) fail by try_crossjump_bb didn't occur.
try_crossjump_bb (remove insns in basic block 6) fail by comparison
between insn 9 and insn 8 not eqaul.
The comparison in function can_replace_by use REG_EQUAL to compare
register content.
The REG_EQAUL lost in insn 9, so the comparison fail.
But we may still have chance to remove basic block 6 in this case.
Because right hand value of insn 9 is already a constant.
We could get comparison equal by comparing between insn 8's register
note and insn 9's RHS if RHS is a constant integer.
Possible patch for can_replace_by in cfgcleanup.c.
- if (!note1 || !note2 || !rtx_equal_p (XEXP (note1, 0), XEXP (note2, 0))
- || !CONST_INT_P (XEXP (note1, 0)))
+
+ if (!note1 || !CONST_INT_P (XEXP (note1, 0)))
return dir_none;
+ if (note2)
+ {
+ if (!rtx_equal_p (XEXP (note1, 0), XEXP (note2, 0)))
+ return dir_none;
+ }
+ else
+ {
+ if (!CONST_INT_P (SET_SRC (s2))
+ || !rtx_equal_p (XEXP (note1, 0), SET_SRC (s2)))
+ return dir_none;
+ }
+
I'm not sure the idea is ok or it might crash something.
Any suggestion would be very helpful.
Thanks in advance.
Shiva Chen