This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fwprop and zero_extract
- From: Amir Gonnen <amirgonnen at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 4 Nov 2009 14:38:10 +0200
- Subject: fwprop and zero_extract
(gcc-4.4.1, proprietary backend)
Hi,
It looks like fwprop does not propagate addresses that appear in
zero_extract on the set dest.
Here is an example:
(insn 8 5 9 2 c:\mingw\home\amirg\test\test.c:157 (set (reg/f:HI 46)
(const:HI (plus:HI (symbol_ref:HI ("r") [flags 0x40] <var_decl
0x2ee40b0 r>)
(const_int 68 [0x44])))) 18 {*movhi} (nil))
(insn 9 8 0 2 c:\mingw\home\amirg\test\test.c:157 (set
(zero_extract:SI (mem/s/j:QI (plus:HI (reg/f:HI 46)
(const_int 2 [0x2])) [0 S1 A8])
(const_int 1 [0x1])
(const_int 1 [0x1]))
(const_int 0 [0x0])) 29 {*movb_lh} (nil))
The problem seems to be in df_scan.c: df_uses_record doesn't handle
the case of (set (zero_extract(mem(...) ...) ...).
So I tried the following patch in df_uses_record under case SET: ...
case ZERO_EXTRACT: ...
--- df-scan.c
+++ df-scan.c
@@ -3152,11 +3152,24 @@
{
width = INTVAL (XEXP (dst, 1));
offset = INTVAL (XEXP (dst, 2));
- mode = GET_MODE (dst);
+ mode = GET_MODE (dst);
+ /* AG start */
+ /* Handle the case of zero_extract(mem(...)) in the set dest */
+ if (GET_CODE (XEXP (dst,0)) == MEM)
+ {
+ df_uses_record (DF_REF_EXTRACT, collection_rec, &XEXP (XEXP (dst,0), 0),
+ DF_REF_REG_MEM_STORE, bb, insn_info,
+ DF_REF_ZERO_EXTRACT,
+ width, offset, mode);
+ }
+ else
+ {
+ /* AG end */
df_uses_record (DF_REF_EXTRACT, collection_rec, &XEXP (dst, 0),
DF_REF_REG_USE, bb, insn_info,
DF_REF_READ_WRITE | DF_REF_ZERO_EXTRACT,
width, offset, mode);
+ } /* AG added closing brackets */
}
else
{
and now fwprop propagates properly:
(insn 9 5 0 2 c:\mingw\home\amirg\test\test.c:157 (set
(zero_extract:SI (mem/s/j:QI (const:HI (plus:HI (symbol_ref:HI ("r")
[flags 0x40] <var_decl 0x2ee40b0 r>)
(const_int 70 [0x46]))) [0 S1 A8])
(const_int 1 [0x1])
(const_int 1 [0x1]))
(const_int 0 [0x0])) 29 {*movb_lh} (nil))
I'll appreciate any comments,
Thanks,
Amir