This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Adding constants to LO_SUM
- To: gcc at gcc dot gnu dot org
- Subject: Adding constants to LO_SUM
- From: Roman Lechtchinsky <rl at cs dot tu-berlin dot de>
- Date: Mon, 9 Jul 2001 18:00:22 +0200 (MET DST)
- cc: kenner at vlsi1 dot ultra dot nyu dot edu
Hi,
the patch
http://gcc.gnu.org/ml/gcc-patches/2001-07/msg00166.html
essentially make plus_constant_wide transform expressions of the form
lo_sum(a,b)+c to lo_sum(a,b+c). I think this is incorrect as the first
expression essentially evaluates to a + (b & MASK) + c whereas the second
one evaluates to a + ((b + c) & MASK). The two are clearly not equivalent.
In particular, this causes a bootstrap failure on the Sparc because the
following sequence
(insn 9 8 10 (set (reg:SI 108)
(high:SI (symbol_ref:SI ("G")))) -1 (nil)
(nil))
(insn 10 9 20 (set (reg/f:SI 107)
(lo_sum:SI (reg:SI 108)
(symbol_ref:SI ("G")))) -1 (nil)
(expr_list:REG_EQUAL (symbol_ref:SI ("G"))
(nil)))
(insn 22 20 23 (set (mem/s:SI (plus:SI (reg/f:SI 107)
(const_int 1296 [0x510])) 0)
(reg:SI 109)) -1 (nil)
(nil))
is transformed to
(insn 9 328 17 (set (reg/f:SI 108)
(high:SI (symbol_ref:SI ("G")))) 53 {*movsi_high} (nil)
(expr_list:REG_EQUAL (high:SI (symbol_ref:SI ("G")))
(nil)))
...
(insn 22 20 23 (set (mem/s:SI (lo_sum:SI (reg/f:SI 108)
(const:SI (plus:SI (symbol_ref:SI ("G"))
(const_int 1296 [0x510])))) 0)
(reg:SI 109)) 51 {*movsi_insn} (nil)
(nil))
which results in (reg:SI 109) being stored in a completely bogus memory
location because (plus:SI (symbol_ref:SI ("G")) (const_int 1296))
overflows the bits which lo_sum operates upon. I'm not absolutely sure
that it is the above patch which causes the problem but it looks like a
good candidate so I just wanted to ask - I don't have time to do more
testing right now.
Bye
Roman