public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: Ian Lance Taylor <iant@google.com>, GCC <gcc@gcc.gnu.org>
Subject: Re: Latent bug in update_equiv_regs?
Date: Thu, 20 Aug 2009 14:27:00 -0000	[thread overview]
Message-ID: <4A8D519D.5020705@redhat.com> (raw)
In-Reply-To: <84fc9c000908200145l53d0e86dt47ddf3ecb8f02ee3@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 930 bytes --]

On 08/20/09 02:45, Richard Guenther wrote:
>
> It looks indeed bogus.  Do you have a testcase at hand?
>    
Compile the attached testcase with -O3 -mopenmp on i686-pc-linux-gnu.  
Find MAIN__.omp_fn.2 in the .expand dump.

Within that function, you're looking for this sequence of insns:



;; D.3137_29 = REALPART_EXPR <.omp_data_i_55(D)->c>;

(insn 242 241 0 j.f90:138 (set (reg:SF 74 [ D.3137 ])
         (mem/s:SF (plus:SI (reg/f:SI 247 [ .omp_data_i ])
                 (const_int 32 [0x20])) [2 .omp_data_i_55(D)->c+0 S4 
A64])) -1 (nil))

[ ... ]

(insn 247 246 0 j.f90:138 (set (mem/s:SF (plus:SI (reg/f:SI 247 [ 
.omp_data_i ])
                 (const_int 32 [0x20])) [13 S4 A64])
         (reg:SF 351)) -1 (nil))


This doesn't cause a libgomp testsuite failure in the mainline because 
(reg:SF 74) gets a hard reg and thus reload doesn't utilize the bogus 
REG_EQUIV note that eventually gets added to insn 242.

Jeff

[-- Attachment #2: reduction1.f90 --]
[-- Type: text/plain, Size: 4309 bytes --]

! { dg-do run }
!$ use omp_lib

  integer :: i, ia (6), n, cnt
  real :: r, ra (4)
  double precision :: d, da (5)
  complex :: c, ca (3)
  logical :: v

  i = 1
  ia = 2
  r = 3
  ra = 4
  d = 5.5
  da = 6.5
  c = cmplx (7.5, 1.5)
  ca = cmplx (8.5, -3.0)
  v = .false.
  cnt = -1

!$omp parallel num_threads (3) private (n) reduction (.or.:v) &
!$omp & reduction (+:i, ia, r, ra, d, da, c, ca)
!$ if (i .ne. 0 .or. any (ia .ne. 0)) v = .true.
!$ if (r .ne. 0 .or. any (ra .ne. 0)) v = .true.
!$ if (d .ne. 0 .or. any (da .ne. 0)) v = .true.
!$ if (c .ne. cmplx (0) .or. any (ca .ne. cmplx (0))) v = .true.
  n = omp_get_thread_num ()
  if (n .eq. 0) then
    cnt = omp_get_num_threads ()
    i = 4
    ia(3:5) = -2
    r = 5
    ra(1:2) = 6.5
    d = -2.5
    da(2:4) = 8.5
    c = cmplx (2.5, -3.5)
    ca(1) = cmplx (4.5, 5)
  else if (n .eq. 1) then
    i = 2
    ia(4:6) = 5
    r = 1
    ra(2:4) = -1.5
    d = 8.5
    da(1:3) = 2.5
    c = cmplx (0.5, -3)
    ca(2:3) = cmplx (-1, 6)
  else
    i = 1
    ia = 1
    r = -1
    ra = -1
    d = 1
    da = -1
    c = 1
    ca = cmplx (-1, 0)
  end if
!$omp end parallel
  if (v) call abort
  if (cnt .eq. 3) then
    if (i .ne. 8 .or. any (ia .ne. (/3, 3, 1, 6, 6, 8/))) call abort
    if (r .ne. 8 .or. any (ra .ne. (/9.5, 8.0, 1.5, 1.5/))) call abort
    if (d .ne. 12.5 .or. any (da .ne. (/8.0, 16.5, 16.5, 14.0, 5.5/))) call abort
    if (c .ne. cmplx (11.5, -5)) call abort
    if (ca(1) .ne. cmplx (12, 2)) call abort
    if (ca(2) .ne. cmplx (6.5, 3) .or. ca(2) .ne. ca(3)) call abort
  end if

  i = 1
  ia = 2
  r = 3
  ra = 4
  d = 5.5
  da = 6.5
  c = cmplx (7.5, 1.5)
  ca = cmplx (8.5, -3.0)
  v = .false.
  cnt = -1

!$omp parallel num_threads (3) private (n) reduction (.or.:v) &
!$omp & reduction (-:i, ia, r, ra, d, da, c, ca)
!$ if (i .ne. 0 .or. any (ia .ne. 0)) v = .true.
!$ if (r .ne. 0 .or. any (ra .ne. 0)) v = .true.
!$ if (d .ne. 0 .or. any (da .ne. 0)) v = .true.
!$ if (c .ne. cmplx (0) .or. any (ca .ne. cmplx (0))) v = .true.
  n = omp_get_thread_num ()
  if (n .eq. 0) then
    cnt = omp_get_num_threads ()
    i = 4
    ia(3:5) = -2
    r = 5
    ra(1:2) = 6.5
    d = -2.5
    da(2:4) = 8.5
    c = cmplx (2.5, -3.5)
    ca(1) = cmplx (4.5, 5)
  else if (n .eq. 1) then
    i = 2
    ia(4:6) = 5
    r = 1
    ra(2:4) = -1.5
    d = 8.5
    da(1:3) = 2.5
    c = cmplx (0.5, -3)
    ca(2:3) = cmplx (-1, 6)
  else
    i = 1
    ia = 1
    r = -1
    ra = -1
    d = 1
    da = -1
    c = 1
    ca = cmplx (-1, 0)
  end if
!$omp end parallel
  if (v) call abort
  if (cnt .eq. 3) then
    if (i .ne. 8 .or. any (ia .ne. (/3, 3, 1, 6, 6, 8/))) call abort
    if (r .ne. 8 .or. any (ra .ne. (/9.5, 8.0, 1.5, 1.5/))) call abort
    if (d .ne. 12.5 .or. any (da .ne. (/8.0, 16.5, 16.5, 14.0, 5.5/))) call abort
    if (c .ne. cmplx (11.5, -5)) call abort
    if (ca(1) .ne. cmplx (12, 2)) call abort
    if (ca(2) .ne. cmplx (6.5, 3) .or. ca(2) .ne. ca(3)) call abort
  end if

  i = 1
  ia = 2
  r = 4
  ra = 8
  d = 16
  da = 32
  c = 2
  ca = cmplx (0, 2)
  v = .false.
  cnt = -1

!$omp parallel num_threads (3) private (n) reduction (.or.:v) &
!$omp & reduction (*:i, ia, r, ra, d, da, c, ca)
!$ if (i .ne. 1 .or. any (ia .ne. 1)) v = .true.
!$ if (r .ne. 1 .or. any (ra .ne. 1)) v = .true.
!$ if (d .ne. 1 .or. any (da .ne. 1)) v = .true.
!$ if (c .ne. cmplx (1) .or. any (ca .ne. cmplx (1))) v = .true.
  n = omp_get_thread_num ()
  if (n .eq. 0) then
    cnt = omp_get_num_threads ()
    i = 3
    ia(3:5) = 2
    r = 0.5
    ra(1:2) = 2
    d = -1
    da(2:4) = -2
    c = 2.5
    ca(1) = cmplx (-5, 0)
  else if (n .eq. 1) then
    i = 2
    ia(4:6) = -2
    r = 8
    ra(2:4) = -0.5
    da(1:3) = -1
    c = -3
    ca(2:3) = cmplx (0, -1)
  else
    ia = 2
    r = 0.5
    ra = 0.25
    d = 2.5
    da = -1
    c = cmplx (0, -1)
    ca = cmplx (-1, 0)
  end if
!$omp end parallel
  if (v) call abort
  if (cnt .eq. 3) then
    if (i .ne. 6 .or. any (ia .ne. (/4, 4, 8, -16, -16, -8/))) call abort
    if (r .ne. 8 .or. any (ra .ne. (/4., -2., -1., -1./))) call abort
    if (d .ne. -40 .or. any (da .ne. (/32., -64., -64., 64., -32./))) call abort
    if (c .ne. cmplx (0, 15)) call abort
    if (ca(1) .ne. cmplx (0, 10)) call abort
    if (ca(2) .ne. cmplx (-2, 0) .or. ca(2) .ne. ca(3)) call abort
  end if
end

  reply	other threads:[~2009-08-20 13:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-20  0:01 Jeff Law
2009-08-20  0:24 ` Ian Lance Taylor
2009-08-20  1:20   ` Jeff Law
2009-08-20  4:48     ` Ian Lance Taylor
2009-08-20 14:03       ` Jeff Law
2009-08-20  9:48     ` Richard Guenther
2009-08-20 14:27       ` Jeff Law [this message]
2009-08-20 15:11         ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A8D519D.5020705@redhat.com \
    --to=law@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).