Bug 111427 - [14 regression] gfortran.dg/vect/pr60510.f fails after r14-3999-g3c834d85f2ec42
Summary: [14 regression] gfortran.dg/vect/pr60510.f fails after r14-3999-g3c834d85f2ec42
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: 14.0
Assignee: Kewen Lin
URL:
Keywords: testsuite-fail
Depends on:
Blocks:
 
Reported: 2023-09-15 20:17 UTC by seurer
Modified: 2023-10-12 05:12 UTC (History)
4 users (show)

See Also:
Host: powerpc64-linux-gnu
Target: powerpc64-linux-gnu
Build: powerpc64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2023-09-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description seurer 2023-09-15 20:17:27 UTC
g:3c834d85f2ec42c60995c2b678196a06cb744959, r14-3999-g3c834d85f2ec42
make  -k check-gcc RUNTESTFLAGS="--target_board=unix'{-m32,-m64}' vect.exp=gfortran.dg/vect/pr60510.f"

spawn [open ...]
STOP 1
FAIL: gfortran.dg/vect/pr60510.f   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test


commit 3c834d85f2ec42c60995c2b678196a06cb744959
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Thu Sep 14 10:26:48 2023 -0400

    [RA]: Improve cost calculation of pseudos with equivalences


Looks like this actually only happens with -m32.
Comment 1 Vladimir Makarov 2023-09-22 19:15:22 UTC
Unfortunately, I did not manage to reproduce the bug.
Comment 2 Kewen Lin 2023-09-26 06:13:14 UTC
I found it can be reproduced on Power8 but not on Power9 (BE since only BE supports -m32).

The option can be reduced to:

opts="-m32 -funroll-loops -O2 -mcpu=power8"

Looking into the affected test case, IMHO this is a test issue:

      subroutine foo(a,x,y,n)
      implicit none
      integer n,i

      real*8 y(n),x(n),a

      do i=1,n
         a=a+x(i)*y(i)+x(i)
      enddo

      return
      end

      program test
      real*8 x(1024),y(1024),a    ===> line A
      do i=1,1024
        x(i) = i
        y(i) = i+1
      enddo
      call foo(a,x,y,1024)
      if (a.ne.359488000.0) STOP 1
      end

The variable a in line A is an uninitialized variable.

Without the culprit commit, the address of the passed a is 0xfffeec30:

Dump of assembler code for function MAIN__:
   0x100008b0 <+0>:     stwu    r1,-16416(r1)
   ...
   0x100009f4 <+324>:   lis     r12,4096
   0x100009f8 <+328>:   addi    r5,r1,16
   0x100009fc <+332>:   addi    r4,r1,8208
   0x10000a00 <+336>:   addi    r3,r1,16400
   0x10000a04 <+340>:   addi    r6,r12,3160
=> 0x10000a08 <+344>:   bl      0x10000620 <foo_>

(gdb) i r r3
r3             0xfffeec30          4294896688
(gdb) x /2x 0xfffeec30
0xfffeec30:     0x10000524      0x00000000

the random value of "a" is 0x1000052400000000, a tiny float value (1.289846527864432e-231) and doesn't cause the comparison to fail.

With the culprit commit, the address of the passed a is 0xfffeec20:

100008b0 <MAIN__>:
100008b0:       94 21 bf d0     stwu    r1,-16432(r1)
100008b4:       3d 20 10 00     lis     r9,4096
...

(gdb) x /2x 0xfffeec20
0xfffeec20:     0xfffeec40      0x0fddd03c
(gdb) i r r3
r3             0xfffeec20          4294896672

the random value of "a" is 0xfffeec400fddd03c, which is NAN, so it causes the comparison to fail.

I'm not sure why this doesn't get exposed before (so lucky), but an explicit initialization for a should fix this.
Comment 3 Vladimir Makarov 2023-09-29 19:59:21 UTC
Sorry for the inconvenience caused by the patch. I reverted this patch yesterday.
Comment 4 GCC Commits 2023-10-12 05:06:34 UTC
The master branch has been updated by Kewen Lin <linkw@gcc.gnu.org>:

https://gcc.gnu.org/g:610b845a426e26fa86724e5c9d6f74c7a4baf741

commit r14-4581-g610b845a426e26fa86724e5c9d6f74c7a4baf741
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Thu Oct 12 00:04:58 2023 -0500

    testsuite: Avoid uninit var in pr60510.f [PR111427]
    
    The uninitialized variable a in pr60510.f can cause
    some random failures as exposed in PR111427.  This
    patch is to make it initialized accordingly.
    
            PR testsuite/111427
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/vect/pr60510.f (test): Init variable a.
Comment 5 Kewen Lin 2023-10-12 05:12:01 UTC
This failure should be gone as Vladimir reverted the commit exposing this, the fix on uninit var has been also committed.