Bug 35366 - [4.4 Regression] gfortran.dg/equiv_7.f90 fails with -m64 -Os on powerpc-apple-darwin9
Summary: [4.4 Regression] gfortran.dg/equiv_7.f90 fails with -m64 -Os on powerpc-apple...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.4.0
Assignee: Jakub Jelinek
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-02-25 13:29 UTC by Dominique d'Humieres
Modified: 2008-11-12 12:38 UTC (History)
3 users (show)

See Also:
Host: powerpc-apple-darwin9
Target: powerpc-apple-darwin9
Build: powerpc-apple-darwin9
Known to work:
Known to fail:
Last reconfirmed: 2008-11-11 11:27:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominique d'Humieres 2008-02-25 13:29:12 UTC
The test case fortran.dg/equiv_7.f90 fails with -m64 -Os on powerpc-apple-darwin9. I have reduced the code to:

  call derived_types         ! Thanks to Tobias Burnus for this:)
  print *, d1mach (1), transfer ((/0_4, 1048576_4/), 1d0)
  if (d1mach (1) .ne. transfer ((/0_4, 1048576_4/), 1d0)) call abort ()
contains
  function d1mach(i)
    implicit none
    double precision d1mach,dmach(5)
    integer i,large(4),small(4)
    equivalence ( dmach(1), small(1) )
    equivalence ( dmach(2), large(1) )
    data small(1),small(2) / 0,   1048576/
    data large(1),large(2) /-1,2146435071/
    d1mach = dmach(i) 
  end function d1mach
    subroutine derived_types
      TYPE T2
        sequence
        character (3) :: chr = "wxy"
      END TYPE T2
      TYPE(T2) :: a2
      if (a2%chr .ne. "wxy") call abort ()
      end subroutine derived_types
end

I don't see it on i686-apple-darwin9 and it worked at rev. 132355. The failure disappears if I comment the CALL. I wonder if it is not another side effect of rev. 132566:

* config/rs6000/rs6000.h (CONSTANT_ALIGNMENT): Don't overalign
	strings when optimizing for size, unless the target cares about
	alignment.
Comment 1 Dominique d'Humieres 2008-03-13 11:07:10 UTC
If I revert the patch of revision 132566, the failure disappears. It seems that the condition "(STRICT_ALIGNMENT || !optimize_size)" should be tune to handle the -m64 option.

Comment 2 Jakub Jelinek 2008-11-11 11:27:04 UTC
Testing a patch (well, two).
Comment 3 Joost VandeVondele 2008-11-11 16:08:19 UTC
just a note on the patch posted:
http://gcc.gnu.org/ml/gcc-patches/2008-11/msg00407.html

the fortran standard guarantees that
E==TRANSFER(TRANSFER(E,D),E)
if the physical representation of D and E is the same length. 
At the same time, it guarantees that a default logical and a default integer can be storage associated e.g. in a common block (talking about physical storage units). The wording seems somewhat imprecise, but I think it guarantees that the above transfer should work with integer and logical
Comment 4 Jakub Jelinek 2008-11-12 08:17:40 UTC
Subject: Bug 35366

Author: jakub
Date: Wed Nov 12 08:16:12 2008
New Revision: 141782

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141782
Log:
	PR target/35366
	* expr.c (expand_expr_addr_expr_1): If EXP needs bigger alignment
	than INNER and INNER is a constant, forcibly align INNER as much
	as needed.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c

Comment 5 Jakub Jelinek 2008-11-12 12:38:11 UTC
Fixed, either of the patch is sufficient to fix it, though the other patch is still highly desirable.
Comment 6 Jakub Jelinek 2008-11-12 17:03:20 UTC
Subject: Bug 35366

Author: jakub
Date: Wed Nov 12 17:01:51 2008
New Revision: 141790

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141790
Log:
	PR target/35366
	PR fortran/33759
	* fold-const.c (native_encode_string): New function.
	(native_encode_expr): Use it for STRING_CST.

	* trans-const.c (gfc_conv_constant_to_tree): Warn when
	converting an integer outside of LOGICAL's range to
	LOGICAL.
	* trans-intrinsic.c (gfc_conv_intrinsic_function,
	gfc_conv_intrinsic_array_transfer, gfc_conv_intrinsic_transfer):
	Use INTEGER_TYPE instead of BOOLEAN_TYPE for TRANSFER as
	argument of another TRANSFER.

	* gfortran.dg/hollerith.f90: Don't assume a 32-bit value
	stored into logical variable will be preserved.
	* gfortran.dg/transfer_simplify_4.f90: Remove undefined
	cases.  Run at all optimization levels.  Add a couple of
	new tests.
	* gfortran.dg/hollerith5.f90: New test.
	* gfortran.dg/hollerith_legacy.f90: Add dg-warning.

Added:
    trunk/gcc/testsuite/gfortran.dg/hollerith5.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-const.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/hollerith.f90
    trunk/gcc/testsuite/gfortran.dg/hollerith_legacy.f90
    trunk/gcc/testsuite/gfortran.dg/transfer_simplify_4.f90