Bug 25586 - FAIL: gfortran.dg/cray_pointers_2.f90 at -O2 and above
Summary: FAIL: gfortran.dg/cray_pointers_2.f90 at -O2 and above
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2005-12-27 23:30 UTC by John David Anglin
Modified: 2006-05-05 22:50 UTC (History)
2 users (show)

See Also:
Host: hppa64-hp-hpux11.11
Target: hppa64-hp-hpux11.11
Build: hppa64-hp-hpux11.11
Known to work:
Known to fail:
Last reconfirmed:


Attachments
cray_pointers_2.f90.t95.vars (34.78 KB, text/plain)
2005-12-28 00:16 UTC, dave
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2005-12-27 23:30:58 UTC
Executing on host: /test/gnu/gcc-4.1/objdir/gcc/testsuite/../gfortran -B/test/gn

u/gcc-4.1/objdir/gcc/testsuite/../ /test/gnu/gcc-4.1/gcc/gcc/testsuite/gfortran.

dg/cray_pointers_2.f90   -O2  -fcray-pointer  -L/test/gnu/gcc-4.1/objdir/hppa64-

hp-hpux11.11/./libgfortran/.libs -L/test/gnu/gcc-4.1/objdir/hppa64-hp-hpux11.11/

./libgfortran/.libs -L/test/gnu/gcc-4.1/objdir/hppa64-hp-hpux11.11/./libiberty

-lm   -o ./cray_pointers_2.exe    (timeout = 300)

PASS: gfortran.dg/cray_pointers_2.f90  -O2  (test for excess errors)

Setting LD_LIBRARY_PATH to .:/test/gnu/gcc-4.1/objdir/hppa64-hp-hpux11.11/./libg

fortran/.libs:/test/gnu/gcc-4.1/objdir/hppa64-hp-hpux11.11/./libgfortran/.libs:/

test/gnu/gcc-4.1/objdir/gcc:.:/test/gnu/gcc-4.1/objdir/hppa64-hp-hpux11.11/./lib

gfortran/.libs:/test/gnu/gcc-4.1/objdir/hppa64-hp-hpux11.11/./libgfortran/.libs:

/test/gnu/gcc-4.1/objdir/gcc

FAIL: gfortran.dg/cray_pointers_2.f90  -O2  execution test



The fails are at -O2, -O3 -fomit-frame-pointer, -O3 -fomit-frame-pointer

-funroll-loops, -O3 -fomit-frame-pointer -funroll-all-loo ps -finline-functions

and -O3 -g.



# gdb cray_pointers_2.xg

GNU gdb 6.3.50.20051101-cvs

Copyright 2004 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain conditions.

Type "show copying" to see the conditions.

There is absolutely no warranty for GDB.  Type "show warranty" for details.

This GDB was configured as "hppa64-hp-hpux11.11"...

(gdb) r

Starting program: /test/gnu/gcc-4.1/objdir/gcc/testsuite/cray_pointers_2.xg



Program received signal SIGSEGV, Segmentation fault.

0x400000000000e0ec in ptr5_ ()

    at /test/gnu/gcc-4.1/gcc/gcc/testsuite/gfortran.dg/cray_pointers_2.f90:1275

1275         rpte1(i) = i * 5.0

(gdb) disass 0x400000000000e0dc 0x400000000000e0fc

Dump of assembler code from 0x400000000000e0dc to 0x400000000000e0fc:

0x400000000000e0dc <ptr5_+700>: ldd -1b0(sp),r1

0x400000000000e0e0 <ptr5_+704>: copy dp,r4

0x400000000000e0e4 <ptr5_+708>: add,l r1,r6,r5

0x400000000000e0e8 <ptr5_+712>: ldd -260(sp),r19

0x400000000000e0ec <ptr5_+716>: fstw fr22R,r1(r19)

0x400000000000e0f0 <ptr5_+720>: add,l r1,r19,r6

0x400000000000e0f4 <ptr5_+724>: copy r5,r26

0x400000000000e0f8 <ptr5_+728>: ldo -30(sp),ret1

End of assembler dump.

(gdb) p/x $r1

$1 = 0x800003fffeff0898

(gdb) p/x $r19

$2 = 0x0



This appears to be a mixup of base and index registers.
Comment 1 John David Anglin 2005-12-27 23:40:05 UTC
These fails don't occur on 4.2.
Comment 2 Andrew Pinski 2005-12-27 23:47:42 UTC
Can you attach the dump from -fdump-tree-vars?  I suspect that cray_pointers are a bit weird on targets like HPPA since we might not record if it is a pointer or not in the integer.
Comment 3 dave 2005-12-28 00:13:51 UTC
Subject: Re:  FAIL: gfortran.dg/cray_pointers_2.f90  at -O2 and above

> Can you attach the dump from -fdump-tree-vars?  I suspect that cray_pointers
> are a bit weird on targets like HPPA since we might not record if it is a
> pointer or not in the integer.

Will do.  I can see that register r19 has the frame-related flag set
and r1 in .greg:

(insn 1558 191 195 9 (set (reg:DI 1 %r1)
        (mem/f/c:DI (plus:DI (reg/f:DI 30 %r30)
		(const_int -432 [0xfffffffffffffe50])) [538 S8 A64])) 119 {*pa.md:4136} (nil)
    (nil))

(insn 1559 195 187 9 (set (reg/f:DI 19 %r19)
        (mem/f/c:DI (plus:DI (reg/f:DI 30 %r30)
		(const_int -600 [0xfffffffffffffda8])) [517 ivtmp___4698+0 S8 A64])) 119 {*pa.md:4136} (nil)
    (nil))

(insn 187 1559 192 9 (set (reg:DI 6 %r6 [250])
        (plus:DI (reg/f:DI 19 %r19)
	    (reg:DI 1 %r1))) 158 {*pa.md:4941} (nil)
    (nil))

(insn 192 187 199 9 (set (mem/s:SF (reg:DI 6 %r6 [250]) [18 S4 A32])
	(reg:SF 50 %fr22 [254])) 123 {*pa.md:4342} (insn_list:REG_DEP_TRUE 191 (insn_list:REG_DEP_TRUE 187 (nil)))
    (nil))

This allows the peephole2 optimization to form the insn that causes the segv.

Dave
Comment 4 dave 2005-12-28 00:16:15 UTC
Subject: Re:  FAIL: gfortran.dg/cray_pointers_2.f90  at -O2 and above

Here's the dump.

Dave
Comment 5 dave 2005-12-28 00:16:15 UTC
Created attachment 10559 [details]
cray_pointers_2.f90.t95.vars
Comment 6 dave 2005-12-28 00:25:30 UTC
Subject: Re:  FAIL: gfortran.dg/cray_pointers_2.f90  at -O2 and above

> Can you attach the dump from -fdump-tree-vars?  I suspect that cray_pointers
> are a bit weird on targets like HPPA since we might not record if it is a
> pointer or not in the integer.

<L9>:;
  D.1846 = (real4) i;
  D.14918 = (real4 *) ivtmp___4698;
  MEM[index: D.14918 + (real4 *) pretmp___4503] = D.1846 * 5.0e+0;

It I'm reading this correctly, we appear to have the sum of two
real4* pointers in the MEM.

Dave
Comment 7 Andrew Pinski 2005-12-28 00:37:41 UTC
(In reply to comment #6)
> It I'm reading this correctly, we appear to have the sum of two
> real4* pointers in the MEM.

You are reading this correctly.  PRE is only run at -O2 but I don't think this is a PRE bug.

Can you try -fno-ivopts -O2 -fcray-pointer and see if that works and if it does attach the dump provided by -fdump-tree-vars.  I almost think IV-OPTS is going wrong here.

  D.6538 = (real4 *) ivtmp___1132;
  MEM[index: D.6538 + (real4 *) pretmp___1055] = D.4409 * 5.0e+0;

IV-OPTS produces ivtmp___1132 which is a void* and it just increments that.
Comment 8 dave 2005-12-28 04:18:20 UTC
Subject: Re:  FAIL: gfortran.dg/cray_pointers_2.f90  at -O2 and above

> (In reply to comment #6)
> > It I'm reading this correctly, we appear to have the sum of two
> > real4* pointers in the MEM.
> 
> You are reading this correctly.  PRE is only run at -O2 but I don't think this
> is a PRE bug.
> 
> Can you try -fno-ivopts -O2 -fcray-pointer and see if that works and if it does
> attach the dump provided by -fdump-tree-vars.  I almost think IV-OPTS is going
> wrong here.
> 
>   D.6538 = (real4 *) ivtmp___1132;
>   MEM[index: D.6538 + (real4 *) pretmp___1055] = D.4409 * 5.0e+0;
> 
> IV-OPTS produces ivtmp___1132 which is a void* and it just increments that.

It does change things.  The code still seg faults but a little further
on:

Program received signal SIGSEGV, Segmentation fault0x400000000000e0d4 in ptr5_ ()
    at /test/gnu/gcc-4.1/gcc/gcc/testsuite/gfortran.dg/cray_pointers_2.f90:1312
1312            dpte2(j,i)%r1=1.0

(gdb) disass 0x400000000000e0c4 0x400000000000e0e4
Dump of assembler code from 0x400000000000e0c4 to 0x400000000000e0e4:
0x400000000000e0c4 <ptr5_+1364>:        ldd -170(sp),r19
0x400000000000e0c8 <ptr5_+1368>:        ldd -1a8(sp),r20
0x400000000000e0cc <ptr5_+1372>:        copy dp,r4
0x400000000000e0d0 <ptr5_+1376>:        add,l r20,r19,r5
0x400000000000e0d4 <ptr5_+1380>:        fstw fr16R,r20(r19)
0x400000000000e0d8 <ptr5_+1384>:        copy r5,r26
0x400000000000e0dc <ptr5_+1388>:        ldo -30(sp),ret1
0x400000000000e0e0 <ptr5_+1392>:        b,l 0x40000000000033e0 <realne_>,rp
End of assembler dump.
(gdb) p/x $r20
$1 = 0x800003fffeff13ac
(gdb) p/x $r19
$2 = 0x0

Again, we have a base/index register mixup in .greg.

(insn 1537 454 1538 22 /test/gnu/gcc-4.1/gcc/gcc/testsuite/gfortran.dg/cray_poin
ters_2.f90:1312 (set (reg/f:DI 19 %r19)
        (mem/f/c:DI (plus:DI (reg/f:DI 30 %r30)
		(const_int -368 [0xfffffffffffffe90])) [475 S8 A64])) 119 {*pa.md:4136} (nil)
    (nil))

(insn 1538 1537 433 22 /test/gnu/gcc-4.1/gcc/gcc/testsuite/gfortran.dg/cray_poin
ters_2.f90:1312 (set (reg:DI 20 %r20)
        (mem/f/c:DI (plus:DI (reg/f:DI 30 %r30)
		(const_int -424 [0xfffffffffffffe58])) [468 S8 A64])) 119 {*pa.md:4136} (nil)
    (nil))

(insn 433 1538 437 22 /test/gnu/gcc-4.1/gcc/gcc/testsuite/gfortran.dg/cray_pointers_2.f90:1312 (set (reg/f:DI 5 %r5 [354])
        (plus:DI (reg/f:DI 19 %r19)
	    (reg:DI 20 %r20))) 158 {*pa.md:4941} (nil)
   (nil))

(insn 437 433 438 22 /test/gnu/gcc-4.1/gcc/gcc/testsuite/gfortran.dg/cray_pointers_2.f90:1312 (set (mem/s:SF (reg/f:DI 5 %r5 [354]) [18 <variable>.r1+0 S4 A32])
        (reg:SF 44 %fr16 [357])) 123 {*pa.md:4342} (insn_list:REG_DEP_TRUE 433 (nil))
    (expr_list:REG_EQUAL (const_double:SF 1.0e+0 [0x0.8p+1])
	(nil)))

Reloads for insn # 433
Reload 0: reload_in (DI) = (reg:DI 679)
        GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 1)
	reload_in_reg: (reg:DI 679)
	reload_reg_rtx: (reg/f:DI 19 %r19)
Reload 1: reload_in (DI) = (reg/f:DI 632)
	GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 2)
	reload_in_reg: (reg/f:DI 632)
	reload_reg_rtx: (reg:DI 20 %r20)

Dave
Comment 9 John David Anglin 2005-12-30 05:44:20 UTC
Subject: Bug 25586

Author: danglin
Date: Fri Dec 30 05:44:16 2005
New Revision: 109166

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109166
Log:
	PR fortran/25586
	* pa.md: Remove REG_POINTER check from REG+REG peephole2 floating-point
	store patterns.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/pa/pa.md

Comment 10 John David Anglin 2005-12-30 05:47:56 UTC
Subject: Bug 25586

Author: danglin
Date: Fri Dec 30 05:47:53 2005
New Revision: 109167

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109167
Log:
	PR fortran/25586
	* pa.md: Remove REG_POINTER check from REG+REG peephole2 floating-point
	store patterns.


Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/pa/pa.md

Comment 11 John David Anglin 2005-12-30 05:50:47 UTC
Subject: Bug 25586

Author: danglin
Date: Fri Dec 30 05:50:44 2005
New Revision: 109168

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109168
Log:
	PR fortran/25586
	* pa.md: Remove REG_POINTER check from REG+REG peephole2 floating-point
	store patterns.


Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/config/pa/pa.md

Comment 12 John David Anglin 2005-12-30 05:54:21 UTC
Subject: Bug 25586

Author: danglin
Date: Fri Dec 30 05:54:17 2005
New Revision: 109169

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109169
Log:
	PR fortran/25586
	* pa.md: Remove REG_POINTER check from REG+REG peephole2 floating-point
	store patterns.


Modified:
    branches/gcc-3_4-branch/gcc/ChangeLog
    branches/gcc-3_4-branch/gcc/config/pa/pa.md

Comment 13 Steve Ellcey 2006-05-05 22:21:49 UTC
Dave, it looks like this defect has been fixed.  Is there any reason not to close the defect?
Comment 14 John David Anglin 2006-05-05 22:50:18 UTC
Fixed by patch 3.4 and leter.