Bug 53180 - [4.8 Regression] Revision 186378 generates incorrect code for cpu2006 416.gamess
Summary: [4.8 Regression] Revision 186378 generates incorrect code for cpu2006 416.gamess
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-01 20:21 UTC by Pat Haugen
Modified: 2012-05-16 01:38 UTC (History)
2 users (show)

See Also:
Host: powerpc64-linux
Target: powerpc64-linux
Build: powerpc64-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase (5.03 KB, text/plain)
2012-05-01 20:21 UTC, Pat Haugen
Details
Candidate patch (270 bytes, patch)
2012-05-08 10:35 UTC, Bernd Schmidt
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pat Haugen 2012-05-01 20:21:49 UTC
Created attachment 27276 [details]
testcase

416.gamess benchmark started failing with r186378 due to segfault when running the benchmark. I've tracked down to what appears to be bad code for register spilling. Subroutine with bad code is attatched, compile with "gfortran -O3 -m64 -mcpu=power7 -funroll-loops -ffast-math".

Snippets from the dump files for the insns of interest:

193r.ira

r186377:

(insn 6636 6631 6639 43 (set (reg:SI 2943 [ D.2378 ])
        (plus:SI (reg:SI 2944 [ MEM[base: D.4806_3018, index: ivtmp.1254_3009, offset: 0B] ])
            (subreg/s:SI (reg/v:DI 454 [ nx+-4 ]) 4))) hsandt.f:200 78 {*addsi3_internal1}
     (expr_list:REG_DEAD (reg:SI 2944 [ MEM[base: D.4806_3018, index: ivtmp.1254_3009, offset: 0B] ])
        (expr_list:REG_EQUIV (mem:SI (plus:DI (reg/f:DI 4113)
                    (reg:DI 2445 [ D.4808 ])) [3 MEM[base: D.4809_3021, index: ivtmp.1232_213, offset: 0B]+0 S4 A32])
            (nil))))
...
(insn 6637 6632 6640 43 (set (mem:SI (plus:DI (reg/f:DI 4113)
                (reg:DI 2445 [ D.4808 ])) [3 MEM[base: D.4809_3021, index: ivtmp.1232_213, offset: 0B]+0 S4 A32])
        (reg:SI 2943 [ D.2378 ])) hsandt.f:200 377 {*movsi_internal1}
     (expr_list:REG_DEAD (reg/f:DI 4113)
        (expr_list:REG_DEAD (reg:SI 2943 [ D.2378 ])
            (nil))))


r186378:

(insn 6636 6631 6639 43 (set (reg:SI 2943 [ D.2378 ])
        (plus:SI (reg:SI 2944 [ MEM[base: D.4806_3018, index: ivtmp.1254_3009, offset: 0B] ])
            (subreg/s:SI (reg/v:DI 454 [ nx+-4 ]) 4))) hsandt.f:200 78 {*addsi3_internal1}
     (expr_list:REG_DEAD (reg:SI 2944 [ MEM[base: D.4806_3018, index: ivtmp.1254_3009, offset: 0B] ])
        (nil)))
...
(insn 6637 6632 6640 43 (set (mem:SI (plus:DI (reg/f:DI 4113)
                (reg:DI 2445 [ D.4808 ])) [3 MEM[base: D.4809_3021, index: ivtmp.1232_213, offset: 0B]+0 S4 A32])
        (reg:SI 2943 [ D.2378 ])) hsandt.f:200 377 {*movsi_internal1}
     (expr_list:REG_DEAD (reg/f:DI 4113)
        (expr_list:REG_DEAD (reg:SI 2943 [ D.2378 ])
            (nil))))

Note that insn 6636 no longer contains the REG_EQUIV note in r186378. Not sure of the significance yet, but something I noticed.



194r.reload

r186377:

changing reg in insn 6636
changing reg in insn 6637
 Register 2943 now on stack.
...
(insn 6636 6631 8007 43 (set (reg:SI 18 18)
        (plus:SI (reg:SI 18 18 [orig:2944 MEM[base: D.4806_3018, index: ivtmp.1254_3009, offset: 0B] ] [2944])
            (reg:SI 11 11 [orig:454 nx ] [454]))) hsandt.f:200 78 {*addsi3_internal1}
     (expr_list:REG_EQUIV (mem:SI (plus:DI (reg/f:DI 19 19 [4113])
                (reg:DI 6 6 [orig:2445 D.4808 ] [2445])) [3 MEM[base: D.4809_3021, index: ivtmp.1232_213, offset: 0B]+0 S4 A32])
        (nil)))

(insn 8007 6636 6639 43 (set (mem/c:SI (plus:DI (reg/f:DI 19 19 [4113])
                (reg:DI 6 6 [orig:2445 D.4808 ] [2445])) [3 MEM[base: D.4809_3021, index: ivtmp.1232_213, offset: 0B]+0 S4 A32])
        (reg:SI 18 18)) hsandt.f:200 377 {*movsi_internal1}
     (nil))


r186378:

changing reg in insn 6636
changing reg in insn 6637
      Assigning 2943(freq=2) slot 13 of 524 2290
 Register 2943 now on stack.
...
(insn 6636 6631 8052 43 (set (reg:SI 18 18)
        (plus:SI (reg:SI 18 18 [orig:2944 MEM[base: D.4806_3018, index: ivtmp.1254_3009, offset: 0B] ] [2944])
            (reg:SI 11 11 [orig:454 nx ] [454]))) hsandt.f:200 78 {*addsi3_internal1}
     (nil))

(insn 8052 6636 6639 43 (set (mem/c:SI (plus:DI (reg/f:DI 1 1)
                (const_int 17664 [0x4500])) [32 %sfp+17664 S4 A64])
        (reg:SI 18 18)) hsandt.f:200 377 {*movsi_internal1}
     (nil))

In both cases insn 6637 is deleted, but as you can see above r186378 stores to the stack, and that value is not subsequently copied into the original target location of insn 6637.

I can provide more information/details if needed, just don't know what to throw in that will be useful at the moment.

Configured with: /home/pthaugen/src/gcc/temp/gcc/configure --prefix=/home/pthaugen/install/gcc/temp --target=powerpc64-linux --host=powerpc64-linux --build=powerpc64-linux --enable-secureplt --enable-threads=posix --enable-shared --enable-__cxa_atexit --with-long-double-128 --enable-decimal-float --disable-alsa --enable-checking --with-lto --with-as=/home/pthaugen/install/binutils/binutils-2.21.1/bin/as --with-ld=/home/pthaugen/install/binutils/binutils-2.21.1/bin/ld --with-gmp=/home/pthaugen/install/gcc-host-libs --with-mpfr=/home/pthaugen/install/gcc-host-libs --with-mpc=/home/pthaugen/install/gcc-host-libs --with-ppl=/home/pthaugen/install/gcc-host-libs --with-cloog=/home/pthaugen/install/gcc-host-libs --with-host-libstdcxx=-Wl,-Bstatic,-L/home/pthaugen/install/gcc-host-libs/lib,-lstdc++,-Bdynamic,-lm --enable-languages=c,fortran,c++ --disable-bootstrap
Comment 1 Bernd Schmidt 2012-05-08 10:35:21 UTC
Created attachment 27344 [details]
Candidate patch

I think I have a theory of what's going wrong. Can you test this patch?
Comment 2 Pat Haugen 2012-05-08 19:01:02 UTC
(In reply to comment #1)
> Created attachment 27344 [details]
> Candidate patch
> 
> I think I have a theory of what's going wrong. Can you test this patch?

Yes, that patch fixes the problem. It also fixes benchmark h264ref which also started failing on the same revision.
Comment 3 Bernd Schmidt 2012-05-16 01:38:55 UTC
Fixed (r187495)