optimization/7409: loop optimization

Bernhard Kaindl bk@suse.de
Fri Jul 26 05:16:00 GMT 2002


The following reply was made to PR optimization/7409; it has been noted by GNATS.

From: Bernhard Kaindl <bk@suse.de>
To: <hpenner@de.ibm.com>
Cc: <gcc-gnats@gcc.gnu.org>, <mark@codesourcery.com>,
	<uweigand@de.ibm.com>, <nobody@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>, Reinhard Max <max@suse.de>
Subject: Re: optimization/7409: loop optimization 
Date: Fri, 26 Jul 2002 14:11:51 +0200 (CEST)

 On 25 Jul 2002 hpenner@de.ibm.com wrote:
 > >Description:
 > loop_optimize deletes an insn, which should not be deleted.
 > This leads to a abort of an application (tcl).
 
 Yes, it leads to an abort in different 8.x tcl versions when
 running the included testsuite on s390x with gcc-3.1.1-cvs,
 but it looks like it can be worked around by changing the
 -O1 in the Makefile ot -O0 or -O2.
 
 Just to bring all the info together, I append some mails
 also describing the problem, a testcase and a proposed fix.
 
 ---------- Forwarded message ----------
 From: Hartmut Penner <HPENNER@de.ibm.com>
 To: mark@codesourcery.com, gcc-patches@gcc.gnu.org
 Cc: uweigand@de.ibm.com
 Date: Thu, 25 Jul 2002 19:53:53 +0200
 Subject: PR 7409/Loop optimization bug patch
 
 A proposed patch for problem described in PR7409 is appended here.
 The problem was, that the usage of a register as a parameter was not taken
 into acount in the function find_single_use_in_loop.
 
 Index: loop.c
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/loop.c,v
 retrieving revision 1.389.2.7
 diff -u -r1.389.2.7 loop.c
 --- loop.c      15 Jun 2002 01:12:04 -0000      1.389.2.7
 +++ loop.c      25 Jul 2002 17:41:28 -0000
 @@ -3448,6 +3448,19 @@
    const char *fmt = GET_RTX_FORMAT (code);
    int i, j;
 
 +  if (x == PATTERN (insn) && GET_CODE (insn) == CALL_INSN)
 +    {
 +      rtx link;
 +      for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
 +       {
 +         rtx op, reg;
 +
 +         if (GET_CODE (op = XEXP (link, 0)) == USE
 +             && GET_CODE (reg = XEXP (op, 0)) == REG)
 +           regs->array[REGNO (reg)].single_usage = const0_rtx;
 +       }
 +    }
 +
    if (code == REG)
      regs->array[REGNO (x)].single_usage
        = (regs->array[REGNO (x)].single_usage != 0
 
 
 
 Mit freundlichem Gruß / Best regards,
 
 Hartmut Penner
 GCC for S/390 Development
 
 ---------- Forwarded message ----------
 
 The testcase is from Tcl and is accessibel there under the name tclUtil
 which is the file where the problem appears:
 
 http://www.suse.de/~bk/gcc/testcases/
 
 cc -S -g -O1 -fPIC tclUtil.i
 
 This is the assembler code generated to call TclFindElement (only one
 place in the file):
 
         lgfr    %r4,%r8
         la      %r1,184(%r15)
         stg     %r1,160(%r15)
         la      %r1,188(%r15)
         stg     %r1,168(%r15)
         lg      %r2,200(%r15)
         lgr     %r3,%r10
         la      %r5,192(%r15)
 +       la      %r6,176(%r15)
         brasl   %r14,TclFindElement@PLT
 
 Adding the line marked with + fixes the passing of a pointer onto the
 stack and fixes this particulare case.
 
 There are other cases on tcl which -O1 also cause segementation violations,
 I hope that the other cases are also fixed with the patch above, it's likely
 that the conditions of the other uses of TclFindElement are similar.
 
 Best Regards
 Bernhard Kaindl
 
 Research & Development  SuSE Linux S/390 and zSeries
 



More information about the Gcc-prs mailing list