Bug 27707 - g++.dg/tree-ssa/ivopts-1.C fails
Summary: g++.dg/tree-ssa/ivopts-1.C fails
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.4
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 26726
Blocks:
  Show dependency treegraph
 
Reported: 2006-05-21 16:44 UTC by Joseph S. Myers
Modified: 2008-02-01 18:13 UTC (History)
3 users (show)

See Also:
Host:
Target: hppa*-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-05-22 09:05:49


Attachments
ivopts-1.C.085t.ivopts.linux (308 bytes, text/plain)
2006-09-09 18:45 UTC, dave
Details
ivopts-1.C.085t.ivopts.hppa2.0w-hpux11 (344 bytes, text/plain)
2006-09-09 18:45 UTC, dave
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph S. Myers 2006-05-21 16:44:49 UTC
FAIL: g++.dg/tree-ssa/ivopts-1.C scan-tree-dump-not &x\[5\]
FAIL: g++.dg/tree-ssa/ivopts-1.C scan-tree-dump-not offset: -4B

appeared on mainline on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11 when the test was added.
Comment 1 Richard Biener 2006-05-22 09:05:49 UTC
Mine.  I'll add an XFAIL as for x86_64/i?86 - looks like hppa is another target with weird costs.
Comment 2 Richard Biener 2006-05-22 09:20:53 UTC
Fixed.
Comment 3 Richard Biener 2006-05-22 09:21:28 UTC
Subject: Bug 27707

Author: rguenth
Date: Mon May 22 09:20:46 2006
New Revision: 113972

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113972
Log:
2006-05-22  Richard Guenther  <rguenther@suse.de>

	PR testsuite/27707
	* g++.dg/tree-ssa/ivopts-1.C: XFAIL for hppa*-*-*.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/tree-ssa/ivopts-1.C

Comment 4 Richard Biener 2006-06-09 10:24:56 UTC
Fixed.
Comment 5 John David Anglin 2006-09-09 18:25:14 UTC
I would like to request that this bug to be reopened.

First, the test never failed on hppa*-*-linux*, so we now have two
XPASS's on this target.  Second, between 15 and 17 August, the second
xfail for hppa*-*-* changed to an XPASS on hppa*-*-hpux*.  Third,
there's no PR for the "-4B" offset that's still present on hppa*-*-hpux*.

PR 26726, which added the testcase, points to PR target/24669 as
the remaining issue for that issue.  This is characterized as being
a target specific problem, namely that the a more complicated addressing
mode is cheaper than a simpler mode, leading ivopts to prefer the it.
The puzzle in my mind is that there is no obvious difference between
costs for hpux and linux in the PA backend.
Comment 6 Richard Biener 2006-09-09 18:34:20 UTC
I don't know what should be the difference between hpux and linux PA, though this is an issue of IVOPTs and rtl costs.
Comment 7 dave 2006-09-09 18:45:19 UTC
Subject: Re:  g++.dg/tree-ssa/ivopts-1.C fails

> I don't know what should be the difference between hpux and linux PA, though
> this is an issue of IVOPTs and rtl costs.

I've the dump files for hppa-unknown-linux-gnu and hppa2.0w-hp-hpux11.11.

Dave
Comment 8 dave 2006-09-09 18:45:19 UTC
Created attachment 12213 [details]
ivopts-1.C.085t.ivopts.linux
Comment 9 dave 2006-09-09 18:45:19 UTC
Created attachment 12214 [details]
ivopts-1.C.085t.ivopts.hppa2.0w-hpux11
Comment 10 rguenther@suse.de 2006-09-09 20:37:55 UTC
Subject: Re:  g++.dg/tree-ssa/ivopts-1.C fails

On Sat, 9 Sep 2006, dave at hiauly1 dot hia dot nrc dot ca wrote:

> ------- Comment #7 from dave at hiauly1 dot hia dot nrc dot ca  2006-09-09 18:45 -------
> Subject: Re:  g++.dg/tree-ssa/ivopts-1.C fails
> 
> > I don't know what should be the difference between hpux and linux PA, though
> > this is an issue of IVOPTs and rtl costs.
> 
> I've the dump files for hppa-unknown-linux-gnu and hppa2.0w-hp-hpux11.11.

It confirms that it is the same problem as on i?86, but it doesn't tell
why.  I don't see an obvious difference in config/pa/

Richard.
Comment 11 dave 2006-09-10 00:02:30 UTC
Subject: Re:  g++.dg/tree-ssa/ivopts-1.C fails

> It confirms that it is the same problem as on i?86, but it doesn't tell
> why.  I don't see an obvious difference in config/pa/

Yes, it does seem to be the same problem.  The hpux assembler
output has a -4 offset:

        stw %r2,-20(%r30)
L$CFI0000
	ldi 1,%r19
	ldo 128(%r30),%r30
L$CFI0001
	ldo -116(%r30),%r28
	ldo -100(%r30),%r20
	stw %r19,-4(%r28)
L$0008:
	ldo 4(%r28),%r28
	comb,<>,n %r20,%r28,L$0008
	stw %r19,-4(%r28)
        .CALL ARGW0=GR
	bl _Z3fooR3Foo,%r2
	ldo -120(%r30),%r26

The linux output doesn't have the -4 offset:

       ldi 1,%r28
       stw %r2,-20(%r30)
.LCFI0:
       copy %r28,%r21
       ldo 128(%r30),%r30
.LCFI1:
       ldi 4,%r19
       stw %r28,-120(%r30)
       ldo -120(%r30),%r26
       ldi 16,%r20
.L2:
       addl %r19,%r26,%r28
       ldo 4(%r19),%r19
       comb,<> %r20,%r19,.L2
       stw %r21,0(%r28)
       bl _Z3fooR3Foo,%r2
       nop

Offhand, then hpux code appears better optimized.

Dave
Comment 12 dave 2006-09-10 18:39:11 UTC
Subject: Re:  g++.dg/tree-ssa/ivopts-1.C fails

> The linux output doesn't have the -4 offset:
> 
>        ldi 1,%r28
>        stw %r2,-20(%r30)
> .LCFI0:
>        copy %r28,%r21
>        ldo 128(%r30),%r30
> .LCFI1:
>        ldi 4,%r19
>        stw %r28,-120(%r30)
>        ldo -120(%r30),%r26
>        ldi 16,%r20
> .L2:
>        addl %r19,%r26,%r28
>        ldo 4(%r19),%r19
>        comb,<> %r20,%r19,.L2
>        stw %r21,0(%r28)
>        bl _Z3fooR3Foo,%r2
>        nop

It seems like the code generated for the hppa-unknown-linux-gnu target
has been getting worse in each release since 4.0.0.  Here is the 4.0.0
assembler code:

	stw %r2,-20(%r30)
.LCFI0:
	ldi 1,%r19
	ldo 128(%r30),%r30
.LCFI1:
	ldo -120(%r30),%r28
	ldo -104(%r30),%r20
	stw %r19,0(%r28)
.L8:
	ldo 4(%r28),%r28
	comb,<>,n %r28,%r20,.L8
	stw %r19,0(%r28)
	bl _Z3fooR3Foo,%r2
	ldo -120(%r30),%r26

In this code, the function prologue and loop setup are only six instructions.
The loop is three instructions.  The delay slot for the call to _Z3fooR3Foo
is filled.  The value loaded into r26 is the same as loaded into r28 before
the loop.  I would say this code is close to optimal aside from unrolling
loop completely.

Here is the code generated by Debian 4.1.1-13:

	stw %r2,-20(%r30)
.LCFI0:
	ldi 0,%r19
	ldo 128(%r30),%r30
.LCFI1:
	ldi 1,%r21
	ldo -120(%r30),%r26
	ldi 16,%r20
.L2:
	addl %r19,%r26,%r28
	ldo 4(%r19),%r19
	comb,<> %r20,%r19,.L2
	stw %r21,0(%r28)
	bl _Z3fooR3Foo,%r2
	nop

The prologue and loop setup are still six instructions.  However,
the loop is now four instructions per iteration and we iterate one
more time.  Thus, we have a significant performance regression
relative to 4.0.0 in the handling of this loop.

Possibly, this results from the compiler trying to avoid loading the
address "-120(%r30)" twice.  However, the cost for loading small offsets
is the same as doing a register copy.  A register copy is just a ldo
instruction with an offset of 0.

The 4.2.0 code is worse than the 4.1.1 code in that the prologue and
loop setup have now grown to eight instructions.  However, we are
back to three iterations.  It seems like the compiler may be trying
to avoid non-zero offsets.  I don't know why this would be.
hppa_address_cost is pretty simple.

As far as the the difference between linux and hpux goes, the main
difference is that long doubles are 64 bits on linux and 128 bits
on hpux.  This would affect the sizes of the cost arrays in expmed.c.
I'm wondering if somehow some of the values in these tables are
getting corrupted.

There's one puzzling difference in the linux and hpux tree dumps.
In the hpux dump, some variables are "long unsigned int" whereas in
the linux dump they are "unsigned int".

Dave
Comment 13 Mark Mitchell 2007-05-14 22:26:32 UTC
Will not be fixed in 4.2.0; retargeting at 4.2.1.
Comment 14 Mark Mitchell 2007-10-09 19:21:57 UTC
Change target milestone to 4.2.3, as 4.2.2 has been released.
Comment 15 Joseph S. Myers 2008-02-01 16:52:55 UTC
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
Comment 16 Richard Biener 2008-02-01 16:58:40 UTC
Dave, is this test still failing on hppa?  On the branch and trunk?
Comment 17 dave 2008-02-01 18:08:45 UTC
Subject: Re:  g++.dg/tree-ssa/ivopts-1.C fails

> Dave, is this test still failing on hppa?  On the branch and trunk?

It is not failing on either 4.2 or trunk.  Checked hppa-unknown-linux-gnu,
hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

Dave
Comment 18 Richard Biener 2008-02-01 18:13:28 UTC
Thus fixed.
Comment 19 dave 2008-02-01 18:23:16 UTC
Subject: Re:  g++.dg/tree-ssa/ivopts-1.C fails

> Thus fixed.

The test needs adjustment.

Dave