[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] invalid use of reg_unused_after in avr.c
From: |
Tristan Gingold |
Subject: |
[avr-gcc-list] invalid use of reg_unused_after in avr.c |
Date: |
Tue, 2 Dec 2008 10:12:13 +0100 |
Hi,
while trying to understand why gcc generates buggy code, I wondered if
it is safe to use reg_unused_after
(and more particularly dead_or_set_p) while emitting asm.
It looks like liveness information is not maintained after reload.
Here is the issue:
At pass 188.ce3:
BB 18:
...
(insn 166 165 167 18 c730a01.adb:62 (set (cc0)
(reg:HI 16 r16 [ D.1758+2 ])) 87 {tsthi} (expr_list:REG_DEAD
(reg:HI 16 r16 [ D.1758+2 ])
(nil)))
...
BB 20 (its only predecessor is BB 18)
...
(insn 693 176 177 20 c730a01.adb:62 (set (reg:HI 30 r30)
(reg/f:HI 12 r12 [orig:68 SR.20 ] [68])) 8 {*movhi} (nil))
...
But after 190.cprop_hardreg:
(insn 166 165 167 18 c730a01.adb:62 (set (cc0)
(reg:HI 16 r16 [ D.1758+2 ])) 87 {tsthi} (expr_list:REG_DEAD
(reg:HI 16 r16 [ D.1758+2 ])
(nil)))
(insn 693 176 177 20 c730a01.adb:62 (set (reg:HI 30 r30)
(reg:HI 16 r16 [orig:68 SR.20 ] [68])) 8 {*movhi} (nil))
Clearly the use of r16 in insn 693 is wrong as the tsthi (which
generates or r16, r17) kills r16.
As a consequence, the code generated is wrong.
AVR seems to be the only target to use dead_or_set_p so late. Other
targets use peephole optimizations
to address such cases.
Thoughts ?
Tristan.
- [avr-gcc-list] invalid use of reg_unused_after in avr.c,
Tristan Gingold <=