[patch, fortran] Move some array packing to front end

Richard Biener richard.guenther@gmail.com
Wed Jan 23 08:22:00 GMT 2019


On Tue, Jan 22, 2019 at 9:59 PM Thomas Koenig <tkoenig@netcologne.de> wrote:
>
> Hello world,
>
> the attached patch moves the packing / unpacking of arrays to the front
> end when optimizing, but not for size.
>
> Rationale: internal_pack and internal_unpack are opaque to the compiler.
> This can lead to a lot of information loss for inlining and inter-
> procedural optimization, and in extreme cases can lead to huge
> slowdowns.
>
> I don't want to do this for -Os or for -O0.  -Os because I want to avoid
> size increases, and -O0 for several reasons: The current method works
> well, if there should turn out to be a bug still hiding in this code I
> want to at least have "works with -O0" in the bug report, and finally
> I did not want to rewrite all test cases.
>
> Because run test cases cycle through a lot of optimization options,
> I had to split some of them up - test the pattern matches with -O0, test
> for run time correctness under all the options.
>
> I have regression-tested this.  I would, however, prefer if some people
> could run this patch against their non-testsuite code and report
> any problems that this may introduce. So, if you can spare the time
> and the cycles, that would be great.
>
> The nice thing about this kind of patch is that, if this does not
> work for a certain condition, it is usually straightforward to
> check for the condition and then simply not do the optimization.
>
> So, comments?  Bug reports?  OK for trunk if nobody has come
> up with a bug in the next few days?

Note for this kind of changes it is approprate to wait for stage1 to open.

Of course since you're not release critical you can override this
suggestion as you please.

Richard.

> Regards
>
>         Thomas
>
> 2019-01-22  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>          PR fortran/88821
>          * expr.c (gfc_is_simply_contiguous): Return true for
>          an EXPR_ARRAY.
>          * trans-array.c (is_pointer): New function.
>          (gfc_conv_array_parameter): Call gfc_conv_subref_array_arg
>          when not optimizing and not optimizing for size if the formal
>          arg is passed by reference.
>          * trans-expr.c (gfc_conv_subref_array_arg): Add arguments
>          fsym, proc_name and sym.  Add run-time warning for temporary
>          array creation.  Wrap argument if passing on an optional
>          argument to an optional argument.
>          * trans.h (gfc_conv_subref_array_arg): Add optional arguments
>          fsym, proc_name and sym to prototype.
>
> 2019-01-22  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>          PR fortran/88821
>          * gfortran.dg/alloc_comp_auto_array_3.f90: Add -O0 to dg-options
>          to make sure the test for internal_pack is retained.
>          * gfortran.dg/assumed_type_2.f90: Split compile and run time
>          tests into this and
>          * gfortran.dg/assumed_type_2a.f90: New file.
>          * gfortran.dg/c_loc_test_22.f90: Likewise.
>          * gfortran.dg/contiguous_3.f90: Likewise.
>          * gfortran.dg/internal_pack_11.f90: Likewise.
>          * gfortran.dg/internal_pack_12.f90: Likewise.
>          * gfortran.dg/internal_pack_16.f90: Likewise.
>          * gfortran.dg/internal_pack_17.f90: Likewise.
>          * gfortran.dg/internal_pack_18.f90: Likewise.
>          * gfortran.dg/internal_pack_4.f90: Likewise.
>          * gfortran.dg/internal_pack_5.f90: Add -O0 to dg-options
>          to make sure the test for internal_pack is retained.
>          * gfortran.dg/internal_pack_6.f90: Split compile and run time
>          tests into this and
>          * gfortran.dg/internal_pack_6a.f90: New file.
>          * gfortran.dg/internal_pack_8.f90: Likewise.
>          * gfortran.dg/missing_optional_dummy_6: Split compile and run time
>          tests into this and
>          * gfortran.dg/missing_optional_dummy_6a.f90: New file.
>          * gfortran.dg/no_arg_check_2.f90: Split compile and run time tests
>          into this and
>          * gfortran.dg/no_arg_check_2a.f90: New file.
>          * gfortran.dg/typebound_assignment_5.f90: Split compile and run
> time
>          tests into this and
>          * gfortran.dg/typebound_assignment_5a.f90: New file.
>          * gfortran.dg/typebound_assignment_6.f90: Split compile and run
> time
>          tests into this and
>          * gfortran.dg/typebound_assignment_6a.f90: New file.
>          * gfortran.dg/internal_pack_19.f90: New file.
>          * gfortran.dg/internal_pack_20.f90: New file.



More information about the Gcc-patches mailing list