[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-fortran
Subject:    Re: [PATCH] Fix Fortran/29410, transfer vs -O2
From:       Paul Thomas <paulthomas2 () wanadoo ! fr>
Date:       2006-10-30 6:25:19
Message-ID: 45459ACF.9030502 () wanadoo ! fr
[Download RAW message or body]

Andrew,
> The problem here is that the Fortran front-end creates "*(typeof<mold>
> *)&source" which is not alias friendly at all.  We should be using
> VIEW_CONVERT_EXPR instead which is more aliasing friendly.
> This patch changes the front-end to produce VCE.
>   
The code that gfortran produces contains a fair sprinkling of  
"*(typeof<mold>*)&source"'s.  Maybe we need to track down and change all 
such code?
> OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
>   
OK - Thanks, Andrew.

Paul
> Thanks,
> Andrew Pinski
>
> fortran/ChangeLog:
>
> 	* trans-intrinsic.c (gfc_conv_intrinsic_array_transfer):
> 	Change over to create VIEW_CONVERT_EXPR instead of using an
> 	ADDR_EXPR, a cast and then an indirect reference.
>
> testsuite/ChangeLog:
>
> 	* gfortran.fortran-torture/execute/transfer1.f90: New test.
>   
> ------------------------------------------------------------------------
>
> Index: testsuite/gfortran.fortran-torture/execute/transfer1.f90
> ===================================================================
> --- testsuite/gfortran.fortran-torture/execute/transfer1.f90	(revision 0)
> +++ testsuite/gfortran.fortran-torture/execute/transfer1.f90	(revision 0)
> @@ -0,0 +1,10 @@
> +program chop
> +  integer ix, iy
> +  real x, y
> +  x = 1.
> +  y = x
> +  ix = transfer(x,ix)
> +  iy = transfer(y,iy)
> +  print '(2z20.8)', ix, iy
> +  if (ix /= iy) call abort
> +end program chop
> Index: fortran/trans-intrinsic.c
> ===================================================================
> --- fortran/trans-intrinsic.c	(revision 118159)
> +++ fortran/trans-intrinsic.c	(working copy)
> @@ -2914,7 +2914,7 @@ gfc_conv_intrinsic_array_transfer (gfc_s
>  
>  
>  /* Scalar transfer statement.
> -   TRANSFER (source, mold) = *(typeof<mold> *)&source.  */
> +   TRANSFER (source, mold) = VIEW_CONVERT_EXPR<typeof<mold> >source.  */
>  
>  static void
>  gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr)
> @@ -2939,9 +2939,9 @@ gfc_conv_intrinsic_transfer (gfc_se * se
>  
>    arg = arg->next;
>    type = gfc_typenode_for_spec (&expr->ts);
> -  ptr = convert (build_pointer_type (type), ptr);
>    if (expr->ts.type == BT_CHARACTER)
>      {
> +      ptr = convert (build_pointer_type (type), ptr);
>        gfc_init_se (&argse, NULL);
>        gfc_conv_expr (&argse, arg->expr);
>        gfc_add_block_to_block (&se->pre, &argse.pre);
> @@ -2951,7 +2951,8 @@ gfc_conv_intrinsic_transfer (gfc_se * se
>      }
>    else
>      {
> -      se->expr = build_fold_indirect_ref (ptr);
> +      tree tmp = build_fold_indirect_ref (ptr);
> +      se->expr = fold_build1 (VIEW_CONVERT_EXPR, type, tmp);
>      }
>  }
>  
>   


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic