This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

init-regs double initialization


Hi,

I have the very simple:
volatile unsigned int SOME_REGISTER;
volatile unsigned long ANOTHER_REGISTER;

void foo_bar(void)
{
  SOME_REGISTER = 0;
  ANOTHER_REGISTER = 0;
}

causing me some headaches: int is QImode, long is HImode.

Using gcc-4.6.2, in 175r.fwprop2 I have:
(insn 6 2 7 2 (parallel [
(set (mem/v/c/i:QI (symbol_ref:QI ("SOME_REGISTER") <var_decl 0xb7ecd1e0 SOME_REGISTER>) [2 SOME_REGISTER+0 S1 A16])
(const_int 0 [0]))
(clobber (reg:CC 13 CC))
]) test.c:6 6 {*movqi}
(expr_list:REG_UNUSED (reg:CC 13 CC)
(nil)))


(insn 7 6 8 2 (parallel [
            (set (subreg:QI (reg:HI 21) 0)
                (const_int 0 [0]))
            (clobber (reg:CC 13 CC))
        ]) test.c:7 6 {*movqi}
     (expr_list:REG_UNUSED (reg:CC 13 CC)
        (nil)))

(insn 8 7 9 2 (parallel [
            (set (subreg:QI (reg:HI 21) 1)
                (const_int 0 [0]))
            (clobber (reg:CC 13 CC))
        ]) test.c:7 6 {*movqi}
     (expr_list:REG_UNUSED (reg:CC 13 CC)
        (nil)))

(insn 9 8 0 2 (set (mem/v/c/i:HI (symbol_ref:QI ("ANOTHER_REGISTER") <var_decl 0xb7ecd2a0 ANOTHER_REGISTER>) [3 ANOTHER_REGISTER+0 S2 A16])
(reg:HI 21)) test.c:7 13 {*movhi_direct}
(expr_list:REG_DEAD (reg:HI 21)
(nil)))


After 177r.init-regs:
(insn 6 2 12 2 (parallel [
(set (mem/v/c/i:QI (symbol_ref:QI ("SOME_REGISTER") <var_decl 0xb7ecd1e0 SOME_REGISTER>) [2 SOME_REGISTER+0 S1 A16])
(const_int 0 [0]))
(clobber (reg:CC 13 CC))
]) test.c:6 6 {*movqi}
(expr_list:REG_UNUSED (reg:CC 13 CC)
(nil)))


(insn 12 6 13 2 (parallel [
            (set (subreg:QI (reg:HI 21) 0)
                (const_int 0 [0]))
            (clobber (reg:CC 13 CC))
        ]) test.c:7 -1
     (nil))

(insn 13 12 7 2 (parallel [
            (set (subreg:QI (reg:HI 21) 1)
                (const_int 0 [0]))
            (clobber (reg:CC 13 CC))
        ]) test.c:7 -1
     (nil))

(insn 7 13 8 2 (parallel [
            (set (subreg:QI (reg:HI 21) 0)
                (const_int 0 [0]))
            (clobber (reg:CC 13 CC))
        ]) test.c:7 6 {*movqi}
     (expr_list:REG_UNUSED (reg:CC 13 CC)
        (nil)))

(insn 8 7 9 2 (parallel [
            (set (subreg:QI (reg:HI 21) 1)
                (const_int 0 [0]))
            (clobber (reg:CC 13 CC))
        ]) test.c:7 6 {*movqi}
     (expr_list:REG_UNUSED (reg:CC 13 CC)
        (nil)))

(insn 9 8 0 2 (set (mem/v/c/i:HI (symbol_ref:QI ("ANOTHER_REGISTER") <var_decl 0xb7ecd2a0 ANOTHER_REGISTER>) [3 ANOTHER_REGISTER+0 S2 A16])
(reg:HI 21)) test.c:7 13 {*movhi_direct}
(expr_list:REG_DEAD (reg:HI 21)
(nil)))



So insn, 12 and 13 were added to initialize reg21:HI which was already initialized.


I am thinking many things could have gone wrong. First init-regs didn't detect the initialization of reg21 because it's split into subregs but then something should have checked for duplicate insn. However this checking probably didn't work because of the clobbers of RCC in the insns.

Any hints of what might be going on? These duplicates reach register allocation and cause unnecessary assembly instructions to be emitted.

Cheers,
--
PMatos


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]