Article View: gnu.gcc.bug
Article #6391Bug in function.c
From: Thomas Lundqvist
Date: Thu, 23 Nov 1995 00:00
Date: Thu, 23 Nov 1995 00:00
103 lines
4386 bytes
4386 bytes
A bug exists in function.c (version 2.7.0), in the function:
'fixup_var_refs_1'.
Bug: The function 'single_set' is called from two different places
with the wrong type of argument. It should be changed from
'PATTERN (insn)' to 'insn'.
Symptom: The bug causes 'single_set' to always return 0. This will
cause an unnecessary copying via a new pseudo register.
There will probably be no visible differences, since this
copying is likely to be removed when optimizing.
The following program might be helpful when examining the bug:
void main ()
{
double a;
a = 3.0;
fun (&a);
}
Compile with/without optimization and compare the .rtl files. The extra
copying should appear on any platform (we believe). The compiler will
first put the variable 'a' in a register. When the address of 'a'
is needed it must fix up all var refs to change them into a stack slot
instead. This is were it fails, instead of just changing the references,
it inserts extra code to make a copying via a pseudo register.
============================================================ Bug fix:
*** function.c.2.7.0 Wed Nov 22 15:25:33 1995
--- function.c.fixed Wed Nov 22 15:26:28 1995
***************
*** 1934,1946 ****
if ((SET_SRC (x) == var
|| (GET_CODE (SET_SRC (x)) == SUBREG
&& SUBREG_REG (SET_SRC (x)) == var))
&& (GET_CODE (SET_DEST (x)) == REG
|| (GET_CODE (SET_DEST (x)) == SUBREG
&& GET_CODE (SUBREG_REG (SET_DEST (x))) == REG))
! && x == single_set (PATTERN (insn)))
{
rtx pat;
replacement = find_fixup_replacement (replacements, SET_SRC (x));
if (replacement->new)
SET_SRC (x) = replacement->new;
--- 1934,1946 ----
if ((SET_SRC (x) == var
|| (GET_CODE (SET_SRC (x)) == SUBREG
&& SUBREG_REG (SET_SRC (x)) == var))
&& (GET_CODE (SET_DEST (x)) == REG
|| (GET_CODE (SET_DEST (x)) == SUBREG
&& GET_CODE (SUBREG_REG (SET_DEST (x))) == REG))
! && x == single_set (insn))
{
rtx pat;
replacement = find_fixup_replacement (replacements, SET_SRC (x));
if (replacement->new)
SET_SRC (x) = replacement->new;
***************
*** 1979,1991 ****
if ((SET_DEST (x) == var
|| (GET_CODE (SET_DEST (x)) == SUBREG
&& SUBREG_REG (SET_DEST (x)) == var))
&& (GET_CODE (SET_SRC (x)) == REG
|| (GET_CODE (SET_SRC (x)) == SUBREG
&& GET_CODE (SUBREG_REG (SET_SRC (x))) == REG))
! && x == single_set (PATTERN (insn)))
{
rtx pat;
if (GET_CODE (SET_DEST (x)) == SUBREG)
SET_DEST (x) = fixup_memory_subreg (SET_DEST (x), insn, 0);
else
--- 1979,1991 ----
if ((SET_DEST (x) == var
|| (GET_CODE (SET_DEST (x)) == SUBREG
&& SUBREG_REG (SET_DEST (x)) == var))
&& (GET_CODE (SET_SRC (x)) == REG
|| (GET_CODE (SET_SRC (x)) == SUBREG
&& GET_CODE (SUBREG_REG (SET_SRC (x))) == REG))
! && x == single_set (insn))
{
rtx pat;
if (GET_CODE (SET_DEST (x)) == SUBREG)
SET_DEST (x) = fixup_memory_subreg (SET_DEST (x), insn, 0);
else
============================================================
Regards,
Thomas Lundqvist, d0thomas@dtek.chalmers.se
Harry Gunnarson, d1harry@dtek.chalmers.se
(The bug was found when doing a port to Thor, a microprocessor
designed at Saab Ericsson Space AB, which have a stack-based
instruction set and 2 delay slots. For more information send
e-mail to thor@space.se)
Technical Details
Message-ID:
<199511230758.IAA13656@pirenne.dtek.chalmers.se>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,bd0281ccade6f664,start X-Google-Attributes: gid113d02,public From: d0thomas@dtek.chalmers.se (Thomas Lundqvist) Subject: Bug in function.c Date: 1995/11/23 Message-ID: <199511230758.IAA13656@pirenne.dtek.chalmers.se> X-Deja-AN: 119950298 distribution: gnu sender: daemon@cis.ohio-state.edu organization: GNUs Not Usenet newsgroups: gnu.gcc.bug