public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/20066] New: Ordering of clogical onstants determines if they're correctly emitted
@ 2005-02-19 10:49 tobi at gcc dot gnu dot org
  2005-02-19 11:16 ` [Bug middle-end/20066] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-02-19 10:49 UTC (permalink / raw)
  To: gcc-bugs

There's a difference between the assembly emitted for the following two Fortran
tests:
   PRINT *, .TRUE., .TRUE_8 ; END
and
   PRINT *, .TRUE._8, .TRUE ; END

Where for the former we get
        .align 4
.LC1:
        .long   1
the latter gives:
        .align 8
.LC1:
        .long   1
        .long   0
        .text
and in both cases the constants are referenced by pointing to .LC1, i.e. the
code for the PRINT-statements looks like:
        pushl   $8     ;; or $4 for the 4-byte true
        pushl   $.LC1
        call    _gfortran_transfer_logical

In other words, the code is correct for the former program, but not for the
latter, as here both alignment may be wrong and memory beyond the correctly
initialized space will be read.

Andrew Pinski confirmed that the same difference also exists on powerpc, I
assume that this will make 4-byte .TRUE. to always be evaluated to .FALSE. on
that platform.  On ix86 on the other hand an .FALSE._8 will be evaluating to
true if subsequent memory is non-zero.

NB I mark this as blocking PR19543, I don't know if this is the only issue
remaining with that PR.  Also, I made the component rtl-optimization, as the
tree dumps look correct.

-- 
           Summary: Ordering of clogical onstants determines if they're
                    correctly emitted
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobi at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
OtherBugsDependingO 19543
             nThis:


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


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

* [Bug middle-end/20066] Ordering of clogical onstants determines if they're correctly emitted
  2005-02-19 10:49 [Bug rtl-optimization/20066] New: Ordering of clogical onstants determines if they're correctly emitted tobi at gcc dot gnu dot org
@ 2005-02-19 11:16 ` pinskia at gcc dot gnu dot org
  2005-02-19 11:39 ` tobi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-19 11:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-18 22:30 -------
Confirmed, middle-end is closer to the reality as this happens without optimization on.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|rtl-optimization            |middle-end
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-18 22:30:47
               date|                            |


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


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

* [Bug middle-end/20066] Ordering of clogical onstants determines if they're correctly emitted
  2005-02-19 10:49 [Bug rtl-optimization/20066] New: Ordering of clogical onstants determines if they're correctly emitted tobi at gcc dot gnu dot org
  2005-02-19 11:16 ` [Bug middle-end/20066] " pinskia at gcc dot gnu dot org
@ 2005-02-19 11:39 ` tobi at gcc dot gnu dot org
  2005-02-19 11:45 ` [Bug middle-end/20066] Ordering of logical constants " tobi at gcc dot gnu dot org
  2005-02-20  8:55 ` tobi at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-02-19 11:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-02-18 22:31 -------
(In reply to comment #0)
> In other words, the code is correct for the former program, but not for the
> latter, as here both alignment may be wrong and memory beyond the correctly
> initialized space will be read.

... the code is correct for the latter program, but not for the first ...

-- 


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


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

* [Bug middle-end/20066] Ordering of logical constants determines if they're correctly emitted
  2005-02-19 10:49 [Bug rtl-optimization/20066] New: Ordering of clogical onstants determines if they're correctly emitted tobi at gcc dot gnu dot org
  2005-02-19 11:16 ` [Bug middle-end/20066] " pinskia at gcc dot gnu dot org
  2005-02-19 11:39 ` tobi at gcc dot gnu dot org
@ 2005-02-19 11:45 ` tobi at gcc dot gnu dot org
  2005-02-20  8:55 ` tobi at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-02-19 11:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-02-18 22:34 -------
I should also add amphasis to the point that this only happens for LOGICAL
constants. To see how they're defined, look at gfc_build_logical_type in
fortran/trans-types.c.

-- 


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


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

* [Bug middle-end/20066] Ordering of logical constants determines if they're correctly emitted
  2005-02-19 10:49 [Bug rtl-optimization/20066] New: Ordering of clogical onstants determines if they're correctly emitted tobi at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-02-19 11:45 ` [Bug middle-end/20066] Ordering of logical constants " tobi at gcc dot gnu dot org
@ 2005-02-20  8:55 ` tobi at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-02-20  8:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-02-19 22:54 -------
One more data point:
depending on the order of the functions test1 and test8 the following testcase
will print different results on ix86:
character*2 :: t(2), f(2), test1, test8

t(1) = test1(1)
f(1) = test1(0)
t(2) = test8(1)
f(2) = test8(0)

print *, t
print *, f
end
function test8(i) result(r)
  integer :: i
  character*2 :: r

  if (i==1) then
     write (r, *) .TRUE._8
  else
     write (r, *) .FALSE._8
  end if
end function test8
function test1(i) result(r)
  integer :: i
  character*2 :: r

  if (i==1) then
     write (r, *) .TRUE._1
  else
     write (r, *) .FALSE._1
  end if
end function test1

if test8 comes in front of test1 we get the correct:
  T T
  F F
if test1 comes first (that is, if the order of the functions, not the calls, is
interchanged):
  T T
  F T
which is wrong in the logical(8) case.

The assembly shows the same anomaly as I pointed out in the initial bug report.

-- 


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


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

* [Bug middle-end/20066] Ordering of logical constants determines if they're correctly emitted
       [not found] <bug-20066-8513@http.gcc.gnu.org/bugzilla/>
@ 2006-02-20 16:13 ` fxcoudert at gcc dot gnu dot org
  0 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-02-20 16:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2006-02-20 16:13 -------
This is indeed a dup of 19543 (at least, it's fixed by the same patch).

*** This bug has been marked as a duplicate of 19543 ***


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2006-02-20 16:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-19 10:49 [Bug rtl-optimization/20066] New: Ordering of clogical onstants determines if they're correctly emitted tobi at gcc dot gnu dot org
2005-02-19 11:16 ` [Bug middle-end/20066] " pinskia at gcc dot gnu dot org
2005-02-19 11:39 ` tobi at gcc dot gnu dot org
2005-02-19 11:45 ` [Bug middle-end/20066] Ordering of logical constants " tobi at gcc dot gnu dot org
2005-02-20  8:55 ` tobi at gcc dot gnu dot org
     [not found] <bug-20066-8513@http.gcc.gnu.org/bugzilla/>
2006-02-20 16:13 ` fxcoudert 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).