public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31994]  New: conjg(transpose(a)) produces wrong answer.
@ 2007-05-19  0:08 elizabeth dot l dot yip at boeing dot com
  2007-05-19  2:29 ` [Bug fortran/31994] " jvdelisle at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: elizabeth dot l dot yip at boeing dot com @ 2007-05-19  0:08 UTC (permalink / raw)
  To: gcc-bugs

conjg(transpose(a)) produces the wrong answers. Both absoft and ifort  
produce correct answers.

program main
  implicit none
  complex (kind=4),dimension(2,2)::a,b,c
  a(1,1) = (1.,1.)
  a(2,1) = (2.,2.)
  a(1,2) = (3.,3.)
  a(2,2) = (4.,4.)
  print *,"original",a
  b=conjg(transpose(a))
  print *,"H(a)-wrong",b
  c=transpose(a)
  c=conjg(c)
  print *,"H(a)-right",c
END program main


-- 
           Summary: conjg(transpose(a)) produces wrong answer.
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: elizabeth dot l dot yip at boeing dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
@ 2007-05-19  2:29 ` jvdelisle at gcc dot gnu dot org
  2007-05-19  2:38 ` jvdelisle at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-05-19  2:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jvdelisle at gcc dot gnu dot org  2007-05-19 03:29 -------
I see it here too.  This is a frontend problem I think.  Looks to me like its
the transpose portion looking at -fdump-tree-original.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-05-19 03:29:11
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
  2007-05-19  2:29 ` [Bug fortran/31994] " jvdelisle at gcc dot gnu dot org
@ 2007-05-19  2:38 ` jvdelisle at gcc dot gnu dot org
  2007-05-19  9:12 ` dfranke at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-05-19  2:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2007-05-19 03:38 -------
Adding FX to cc. This is not a regression relative to 4.1, but its sure ugly!


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org
           Keywords|                            |wrong-code


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
  2007-05-19  2:29 ` [Bug fortran/31994] " jvdelisle at gcc dot gnu dot org
  2007-05-19  2:38 ` jvdelisle at gcc dot gnu dot org
@ 2007-05-19  9:12 ` dfranke at gcc dot gnu dot org
  2007-05-20  9:52 ` tkoenig at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-05-19  9:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dfranke at gcc dot gnu dot org  2007-05-19 10:11 -------
On 
  a = transpose(b)
  a = transpose(conjg(b))
the TRANSPOSE intrinsic is translated via trans-intrinsic.c
(gfc_conv_intrinsic_funcall) and results in a library call
(_gfortran_transpose_c4), on
  a = conjg(transpose(b))
translation is done via trans-array.c (gfc_conv_array_transpose) - no library
function is called.

The latter fails.


-- 

dfranke at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dfranke at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (2 preceding siblings ...)
  2007-05-19  9:12 ` dfranke at gcc dot gnu dot org
@ 2007-05-20  9:52 ` tkoenig at gcc dot gnu dot org
  2007-05-20 14:40 ` fxcoudert at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-05-20  9:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from tkoenig at gcc dot gnu dot org  2007-05-20 10:52 -------
b = transpose(conjg(a)) works (also translated into
the library call).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (3 preceding siblings ...)
  2007-05-20  9:52 ` tkoenig at gcc dot gnu dot org
@ 2007-05-20 14:40 ` fxcoudert at gcc dot gnu dot org
  2007-05-20 14:43 ` fxcoudert at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-05-20 14:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2007-05-20 15:40 -------
For some reason, the scalarization of conjg(transpose()) is messed up. The
following code:

  complex :: a(1,1), b(1,1)
  a = 0
  b = conjg(transpose(a))
  print *, b(1,1)
  end

ends up as folllows:

      int4 D.1015;
      int4 S.2;

      D.1015 = atmp.1.dim[0].stride;
      S.2 = 1;
      while (1)
        {
          if (S.2 > 1) goto L.2;
          {
            int4 D.1018;
            int4 D.1017;
            int4 S.3;

            D.1017 = parm.0.offset + atmp.1.dim[1].stride * S.2;
            D.1018 = S.2 + -2;
            S.3 = 1;
            while (1)
              {
                if (S.3 > 1) goto L.1;
                b[S.3 + D.1018] = CONJ_EXPR <(*(complex4[0:] *)
parm.0.data)[S.3 * D.1015 + D.1017]>;
                S.3 = S.3 + 1;
              }
            L.1:;
          }
          S.2 = S.2 + 1;
        }
      L.2:;

This makes D.1017 be 1, while it should be -1 (or so I think). What is more
confusing is that I can't trigger this scalarization bug with other intrinsics
such as MAX (code below), nor can I understand what is CONJG-specific here...

The following works as expected:

  integer :: a(1,1), b(1,1)
  a = 0
  b = max(transpose(a),a)
  print *, b(1,1)
  end

Maybe there is something to investigate in the difference between these two
codes.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (4 preceding siblings ...)
  2007-05-20 14:40 ` fxcoudert at gcc dot gnu dot org
@ 2007-05-20 14:43 ` fxcoudert at gcc dot gnu dot org
  2007-05-20 16:08 ` jvdelisle at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-05-20 14:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from fxcoudert at gcc dot gnu dot org  2007-05-20 15:43 -------
(In reply to comment #5)
> What is more
> confusing is that I can't trigger this scalarization bug with other intrinsics

10 seconds after I hit the Commit button, I thought about another testcase, and
it does also trigger the bug:

  integer :: a(1,1)
  real :: b(1,1)
  a = 0
  b = real(transpose(a))
  print *, b(1,1)
  end

This time, the interesting thing is that changing "b = real(transpose(a))" into
"b = transpose(a)" gets rid of the bug. I think it's somewhere hidden in the
intrinsics scalarization, but can't find it. Hopefully someone can go further
with this information!


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2007-05-19 03:29:11         |2007-05-20 15:43:41
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (5 preceding siblings ...)
  2007-05-20 14:43 ` fxcoudert at gcc dot gnu dot org
@ 2007-05-20 16:08 ` jvdelisle at gcc dot gnu dot org
  2007-05-21  9:13 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-05-20 16:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jvdelisle at gcc dot gnu dot org  2007-05-20 17:08 -------
I think it may have to do with the order of resolving,  I think pr32002 is not
picking up the shape checking because the array variables are not resolved
before functions using them are resolved.  I think something similar could be
happening here.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (6 preceding siblings ...)
  2007-05-20 16:08 ` jvdelisle at gcc dot gnu dot org
@ 2007-05-21  9:13 ` pault at gcc dot gnu dot org
  2007-05-21 13:16 ` pault at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-21  9:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pault at gcc dot gnu dot org  2007-05-21 10:13 -------
My patch for PR31867 fixes this in all its manifestations: see
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg00961.html

The amusing thing is that I was hurting for testcases for this latter PR:)

It shows what a limited imagination is incapable of.....

Thanks, Elizabeth.

Perhaps FX or Jerry, you could review the above patch?  I will incorporate
Elizabeth and FX's examples into the PR31867 testscase.

Cheers

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |31867
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-05-20 15:43:41         |2007-05-21 10:13:42
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (7 preceding siblings ...)
  2007-05-21  9:13 ` pault at gcc dot gnu dot org
@ 2007-05-21 13:16 ` pault at gcc dot gnu dot org
  2007-05-21 13:22 ` pault at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-21 13:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pault at gcc dot gnu dot org  2007-05-21 14:16 -------
Subject: Bug 31994

Author: pault
Date: Mon May 21 13:16:06 2007
New Revision: 124903

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124903
Log:
2007-05-21  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/31867
        PR fortran/31994
        * trans-array.c (gfc_conv_expr_descriptor): Obtain the stored
        offset for non-descriptor, source arrays and correct for stride
        not equal to one before writing to field of output descriptor.

2007-05-21  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/31867
        * gfortran.dg/char_length_5.f90: New test.

        PR fortran/31994
        * gfortran.dg/array_reference_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/array_reference_1.f90
    trunk/gcc/testsuite/gfortran.dg/char_length_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (8 preceding siblings ...)
  2007-05-21 13:16 ` pault at gcc dot gnu dot org
@ 2007-05-21 13:22 ` pault at gcc dot gnu dot org
  2007-05-26  3:17 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-21 13:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pault at gcc dot gnu dot org  2007-05-21 14:21 -------
Fixed on trunk.  The patch will be backported to 4.2, as soon as the dust has
settled on trunk and 4.2 is open again.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (9 preceding siblings ...)
  2007-05-21 13:22 ` pault at gcc dot gnu dot org
@ 2007-05-26  3:17 ` pinskia at gcc dot gnu dot org
  2007-05-31 18:52 ` pault at gcc dot gnu dot org
  2007-06-10  2:15 ` pinskia at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-26  3:17 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (10 preceding siblings ...)
  2007-05-26  3:17 ` pinskia at gcc dot gnu dot org
@ 2007-05-31 18:52 ` pault at gcc dot gnu dot org
  2007-06-10  2:15 ` pinskia at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-31 18:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from pault at gcc dot gnu dot org  2007-05-31 18:51 -------
Subject: Bug 31994

Author: pault
Date: Thu May 31 18:50:56 2007
New Revision: 125235

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125235
Log:
2007-05-31  Paul Thomas  <pault@gcc.gnu.org>

        backport from trunk

        PR fortran/31483
        * trans-expr.c (gfc_conv_function_call): Give a dummy
        procedure the correct type if it has alternate returns.


        PR fortran/31540
        * resolve.c (resolve_fl_procedure): Resolve constant character
        lengths.

        PR fortran/31867
        PR fortran/31994
        * trans-array.c (gfc_conv_expr_descriptor): Obtain the stored
        offset for non-descriptor, source arrays and correct for stride
        not equal to one before writing to field of output descriptor.

2007-05-31  Paul Thomas  <pault@gcc.gnu.org>

        backport from trunk

        PR fortran/31483
        * gfortran.dg/altreturn_5.f90: New test.

        PR fortran/31540
        * gfortran.dg/char_result_5.f90: New test.

        PR fortran/31867
        * gfortran.dg/char_length_5.f90: New test.

        PR fortran/31994
        * gfortran.dg/array_reference_1.f90: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/altreturn_5.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/array_reference_1.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/char_length_5.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/char_result_13.f90
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/resolve.c
    branches/gcc-4_2-branch/gcc/fortran/trans-array.c
    branches/gcc-4_2-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31994] conjg(transpose(a)) produces wrong answer.
  2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
                   ` (11 preceding siblings ...)
  2007-05-31 18:52 ` pault at gcc dot gnu dot org
@ 2007-06-10  2:15 ` pinskia at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-10  2:15 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.0                       |4.2.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31994


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-06-10  2:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-19  0:08 [Bug fortran/31994] New: conjg(transpose(a)) produces wrong answer elizabeth dot l dot yip at boeing dot com
2007-05-19  2:29 ` [Bug fortran/31994] " jvdelisle at gcc dot gnu dot org
2007-05-19  2:38 ` jvdelisle at gcc dot gnu dot org
2007-05-19  9:12 ` dfranke at gcc dot gnu dot org
2007-05-20  9:52 ` tkoenig at gcc dot gnu dot org
2007-05-20 14:40 ` fxcoudert at gcc dot gnu dot org
2007-05-20 14:43 ` fxcoudert at gcc dot gnu dot org
2007-05-20 16:08 ` jvdelisle at gcc dot gnu dot org
2007-05-21  9:13 ` pault at gcc dot gnu dot org
2007-05-21 13:16 ` pault at gcc dot gnu dot org
2007-05-21 13:22 ` pault at gcc dot gnu dot org
2007-05-26  3:17 ` pinskia at gcc dot gnu dot org
2007-05-31 18:52 ` pault at gcc dot gnu dot org
2007-06-10  2:15 ` pinskia at gcc dot gnu dot org

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).