Re: Fix devirtualization with LTO
On December 24, 2018 8:17:51 PM GMT+01:00, Jan Hubicka wrote: >> On December 24, 2018 4:15:09 PM GMT+01:00, Jan Hubicka > wrote: >> >> UNRESOLVED: g++-dg-lto-devirt-13-01.exe scan-tree-dump-times ssa >> >> "OBJ_TYPE_REF" 0 >> >> UNRESOLVED: g++-dg-lto-devirt-13-11.exe scan-tree-dump-times ssa >> >> "OBJ_TYPE_REF" 0 >> >> UNRESOLVED: g++-dg-lto-devirt-13-21.exe scan-tree-dump-times ssa >> >> "OBJ_TYPE_REF" 0 >> >> UNRESOLVED: g++-dg-lto-devirt-14-01.exe scan-tree-dump-not ssa >> >"A.*foo" >> >> UNRESOLVED: g++-dg-lto-devirt-14-11.exe scan-tree-dump-not ssa >> >"A.*foo" >> >> UNRESOLVED: g++-dg-lto-devirt-23-01.exe scan-wpa-ipa-dump cp >> >"Discovered >> >> a virtual call to" >> > >> >Hmm, it looks like tree dumps may not work in lto testsuite. I >guess I >> >can either disable those tests or move them to ipa directory. I will >> >take a look. >> >> IIRC there's ltrans dump variant now? > >Those are early opts. I was intending to test whether free lang data >disables the transform. I will look into that and add also some >ltrans >checks. Ah, I suppose a - - param free-lang-data might be a good idea for this. Richard. > >Honza >> >> >Honza >>
Re: [Committed] XFAIL gfortran.dg/ieee/ieee_9.f90
On Tue, Dec 25, 2018 at 09:51:03AM +0200, Janne Blomqvist wrote: > On Mon, Dec 24, 2018 at 9:42 PM Steve Kargl < > s...@troutmask.apl.washington.edu> wrote: > > > On Mon, Dec 24, 2018 at 09:29:50PM +0200, Janne Blomqvist wrote: > > > On Mon, Dec 24, 2018 at 8:05 PM Steve Kargl < > > > s...@troutmask.apl.washington.edu> wrote: > > > > > > > I've added the following patch to a recently committed testcase. > > > > > > > > Index: gcc/testsuite/gfortran.dg/ieee/ieee_9.f90 > > > > === > > > > --- gcc/testsuite/gfortran.dg/ieee/ieee_9.f90 (revision 267413) > > > > +++ gcc/testsuite/gfortran.dg/ieee/ieee_9.f90 (working copy) > > > > @@ -1,4 +1,4 @@ > > > > -! { dg-do run } > > > > +! { dg-do run { xfail arm*-*-gnueabi arm*-*-gnueabihf } } > > > > program foo > > > > use ieee_arithmetic > > > > use iso_fortran_env > > > > > > > > > > The problem seems to be that GFortran says the real128 kind value is > 0 > > > (i.e. that the target supports quad precision floating point (with > > software > > > emulation, presumably)), but then trying to use it fails. > > > > > > Would be nice if somebody who cares about arm-none-linux-gnueabihf could > > > help figure out the proper resolution instead of papering over it with > > > XFAIL. > > > > > > But I guess XFAIL is good enough until said somebody turns up. > > > > > > > Thanks for chasing down the details. I have no access to arm*-*-*. > > > > It's a shame the real128 is defined, and arm*-*-* doesn't > > actually use it. I certainly have no time or interest in > > fix this. > > > > I think there are arm systems on the compile farm, but I haven't actually > checked myself, just going by the error messages Sudi Das reported. > > That being said, having slept over it, I actually think there is a problem > with the testcase, and not with arm*. So the errors in the testcase occurs > in code like > > if (real128 > 0) then > p = int(ieee_scalb(real(x, real128), int(i, int8))) > if (p /= 64) stop 3 > end if > > So if real128 is negative, as it should be if the target doesn't support > quad precision float, the branch will never be taken, but the frontend will > still generate code for it (though it will later be optimized away as > unreachable), and that's where the error occurs. So the testcase would need > something like > > integer, parameter :: large_real = max (real64, real128) > ! ... > if (real128 > 0) then > p = int(ieee_scalb(real(x, large_real), int(i, int8))) > if (p /= 64) stop 3 > end if > > If you concur, please consider a patch fixing the testcase and removing the > xfail pre-approved. > Indeed, you are probably correct that gfortran will generate intermediate code and then garbage collect it. This then will give an error for real(..., real128) in the statement for p. If real128 /= 4, 8, 10, or 16. I'll fix the testcase. Do you know if we can get gfortran to pre-define macros for cpp? That is, it would be nice if gfortran would recognize, say, HAVE_GFC_REAL_10 and HAVE_GFC_REAL_16 if the target supports those types. Then the testcase could be copied to ieee_9.F90, and modified to #ifdef HAVE_REAL_16 p = int(ieee_scalb(real(x, 16), int(i, int8))) if (p /= 64) stop 3 #endif -- Steve
[PATCH,fortran] Add pre-defined macros for different available types
Here's a Holiday present for Fortranners. 2018-12-25 Steven G. Kargl * cpp.c (gfc_cpp_init): Add pre-defined macros for INTEGER(1) INTEGER(2), INTEGER(8) and INTEGER(16) if supported. Add pre-defined macros for REAL(10) and REAL(16) if available. * gfortran.texi: Document new macros. As a Fortran compiler is required to have default integer kind, default real kind, and double precision, I did not include macros for these types (ie., there are no __GFC_INTEGER_4__, __GFC_REAL_4__, and __GFC_REAL_8__). This allows code like % cat a.F90 program foo #ifdef __GFC_REAL_16__ real(16) x x = 1 print *, x #endif end program foo % gfcx -o z a.F90 && ./z 1.000 -- Steve Index: gcc/fortran/cpp.c === --- gcc/fortran/cpp.c (revision 267418) +++ gcc/fortran/cpp.c (working copy) @@ -570,6 +570,8 @@ void gfc_cpp_init (void) { int i; + gfc_integer_info *int_info; + gfc_real_info *real_info; if (gfc_option.flag_preprocessed) return; @@ -607,6 +609,26 @@ gfc_cpp_init (void) else if (opt->code == OPT_MT || opt->code == OPT_MQ) deps_add_target (cpp_get_deps (cpp_in), opt->arg, opt->code == OPT_MQ); +} + + for (int_info = gfc_integer_kinds; int_info->kind != 0; int_info++) +{ + if (int_info->kind == 1) + cpp_define (cpp_in, "__GFC_INT_1__=1"); + if (int_info->kind == 2) + cpp_define (cpp_in, "__GFC_INT_2__=1"); + if (int_info->kind == 8) + cpp_define (cpp_in, "__GFC_INT_8__=1"); + if (int_info->kind == 8) + cpp_define (cpp_in, "__GFC_INT_16__=1"); +} + + for (real_info = gfc_real_kinds; real_info->kind != 0; real_info++) +{ + if (real_info->kind == 10) + cpp_define (cpp_in, "__GFC_REAL_10__=1"); + if (real_info->kind == 16) + cpp_define (cpp_in, "__GFC_REAL_16__=1"); } if (gfc_cpp_option.working_directory Index: gcc/fortran/gfortran.texi === --- gcc/fortran/gfortran.texi (revision 267418) +++ gcc/fortran/gfortran.texi (working copy) @@ -418,9 +418,17 @@ statement, the included file is not preprocessed. To files, use the equivalent preprocessor statement @code{#include}. If GNU Fortran invokes the preprocessor, @code{__GFORTRAN__} -is defined and @code{__GNUC__}, @code{__GNUC_MINOR__} and +is defined. The macros @code{__GNUC__}, @code{__GNUC_MINOR__} and @code{__GNUC_PATCHLEVEL__} can be used to determine the version of the compiler. See @ref{Top,,Overview,cpp,The C Preprocessor} for details. + +GNU Fortran supports a number of @code{INTEGER} and @code{REAL} kind types +in additional to the kind types required by the Fortran standard. +The availability of any given kind type is architecture dependent. The +following pre-defined preprocessor macros can be used to conditional +include code for these additional kind types: @code{__GFC_INTEGER_1__}, +@code{__GFC_INTEGER_2__}, @code{__GFC_INTEGER_8__}, @code{__GFC_INTEGER_16__}, +@code{__GFC_REAL_10__}, and @code{__GFC_REAL_16__}. While CPP is the de-facto standard for preprocessing Fortran code, Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines
Re: [PATCH,fortran] Add pre-defined macros for different available types
> +} > + > + for (int_info = gfc_integer_kinds; int_info->kind != 0; int_info++) > +{ > + if (int_info->kind == 1) > + cpp_define (cpp_in, "__GFC_INT_1__=1"); > + if (int_info->kind == 2) > + cpp_define (cpp_in, "__GFC_INT_2__=1"); > + if (int_info->kind == 8) > + cpp_define (cpp_in, "__GFC_INT_8__=1"); > + if (int_info->kind == 8) yes, that's suppose to be 16. > + cpp_define (cpp_in, "__GFC_INT_16__=1"); > +} > + > + for (real_info = gfc_real_kinds; real_info->kind != 0; real_info++) > +{ > + if (real_info->kind == 10) > + cpp_define (cpp_in, "__GFC_REAL_10__=1"); > + if (real_info->kind == 16) > + cpp_define (cpp_in, "__GFC_REAL_16__=1"); > }
[PATCH,fortran] Add support for IEEE_SUBNORMAL
Fortran 2018 has added IEEE_SUBNORMAL, IEEE_POSITIVE_SUBNORMAL, and IEEE_NEGATIVE_SUBNORMAL as counterparts the same features with the DENORMAL name. The attached patch allows gfortran to recognize and do the right thing with these featuers. OK to commit? 2018-12-25 Steven G. Kargl * expr.c (external_spec_function): Add ieee_support_subnormal to list of IEEE inquiry functions. 2018-12-25 Steven G. Kargl * gfortran.map: Expose subnormal functions in dynamic library. * ieee/ieee_arithmetic.F90: Add support for IEEE_SUBNORMAL, IEEE_POSITIVE_SUBNORMAL, and IEEE_NEGATIVE_SUBNORMAL. * ieee/ieee_helper.c: Ditto. * ieee/ieee_features.F90: Add IEEE_SUBNORMAL. -- Steve Index: gcc/fortran/expr.c === --- gcc/fortran/expr.c (revision 267418) +++ gcc/fortran/expr.c (working copy) @@ -3061,6 +3061,7 @@ external_spec_function (gfc_expr *e) || !strcmp (f->name, "ieee_support_halting") || !strcmp (f->name, "ieee_support_datatype") || !strcmp (f->name, "ieee_support_denormal") + || !strcmp (f->name, "ieee_support_subnormal") || !strcmp (f->name, "ieee_support_divide") || !strcmp (f->name, "ieee_support_inf") || !strcmp (f->name, "ieee_support_io") Index: libgfortran/gfortran.map === --- libgfortran/gfortran.map (revision 267418) +++ libgfortran/gfortran.map (working copy) @@ -1573,4 +1573,9 @@ GFORTRAN_9 { _gfortran_sfindloc2_s1; _gfortran_sfindloc2_s4; _gfortran_st_wait_async; + __ieee_arithmetic_MOD_ieee_support_subnormal_10; + __ieee_arithmetic_MOD_ieee_support_subnormal_16; + __ieee_arithmetic_MOD_ieee_support_subnormal_4; + __ieee_arithmetic_MOD_ieee_support_subnormal_8; + __ieee_arithmetic_MOD_ieee_support_subnormal_noarg; }; Index: libgfortran/ieee/ieee_arithmetic.F90 === --- libgfortran/ieee/ieee_arithmetic.F90 (revision 267418) +++ libgfortran/ieee/ieee_arithmetic.F90 (working copy) @@ -55,9 +55,11 @@ module IEEE_ARITHMETIC IEEE_NEGATIVE_INF = IEEE_CLASS_TYPE(3), & IEEE_NEGATIVE_NORMAL = IEEE_CLASS_TYPE(4), & IEEE_NEGATIVE_DENORMAL = IEEE_CLASS_TYPE(5), & +IEEE_NEGATIVE_SUBNORMAL= IEEE_CLASS_TYPE(5), & IEEE_NEGATIVE_ZERO = IEEE_CLASS_TYPE(6), & IEEE_POSITIVE_ZERO = IEEE_CLASS_TYPE(7), & IEEE_POSITIVE_DENORMAL = IEEE_CLASS_TYPE(8), & +IEEE_POSITIVE_SUBNORMAL= IEEE_CLASS_TYPE(8), & IEEE_POSITIVE_NORMAL = IEEE_CLASS_TYPE(9), & IEEE_POSITIVE_INF = IEEE_CLASS_TYPE(10) @@ -795,6 +797,7 @@ REM_MACRO(4,4,4) SUPPORTGENERIC(IEEE_SUPPORT_DATATYPE) SUPPORTGENERIC(IEEE_SUPPORT_DENORMAL) +SUPPORTGENERIC(IEEE_SUPPORT_SUBNORMAL) SUPPORTGENERIC(IEEE_SUPPORT_DIVIDE) SUPPORTGENERIC(IEEE_SUPPORT_INF) SUPPORTGENERIC(IEEE_SUPPORT_IO) @@ -1243,7 +1362,7 @@ SUPPORTMACRO(IEEE_SUPPORT_DATATYPE,16,.true.) #endif SUPPORTMACRO_NOARG(IEEE_SUPPORT_DATATYPE,.true.) -! IEEE_SUPPORT_DENORMAL +! IEEE_SUPPORT_DENORMAL and IEEE_SUPPORT_SUBNORMAL SUPPORTMACRO(IEEE_SUPPORT_DENORMAL,4,.true.) SUPPORTMACRO(IEEE_SUPPORT_DENORMAL,8,.true.) @@ -1254,6 +1373,16 @@ SUPPORTMACRO(IEEE_SUPPORT_DENORMAL,10,.true.) SUPPORTMACRO(IEEE_SUPPORT_DENORMAL,16,.true.) #endif SUPPORTMACRO_NOARG(IEEE_SUPPORT_DENORMAL,.true.) + +SUPPORTMACRO(IEEE_SUPPORT_SUBNORMAL,4,.true.) +SUPPORTMACRO(IEEE_SUPPORT_SUBNORMAL,8,.true.) +#ifdef HAVE_GFC_REAL_10 +SUPPORTMACRO(IEEE_SUPPORT_SUBNORMAL,10,.true.) +#endif +#ifdef HAVE_GFC_REAL_16 +SUPPORTMACRO(IEEE_SUPPORT_SUBNORMAL,16,.true.) +#endif +SUPPORTMACRO_NOARG(IEEE_SUPPORT_SUBNORMAL,.true.) ! IEEE_SUPPORT_DIVIDE Index: libgfortran/ieee/ieee_features.F90 === --- libgfortran/ieee/ieee_features.F90 (revision 267418) +++ libgfortran/ieee/ieee_features.F90 (working copy) @@ -36,6 +36,7 @@ module IEEE_FEATURES type(IEEE_FEATURES_TYPE), parameter, public :: & IEEE_DATATYPE = IEEE_FEATURES_TYPE(0), & IEEE_DENORMAL = IEEE_FEATURES_TYPE(1), & +IEEE_SUBNORMAL = IEEE_FEATURES_TYPE(1), & IEEE_DIVIDE = IEEE_FEATURES_TYPE(2), & IEEE_HALTING= IEEE_FEATURES_TYPE(3), & IEEE_INEXACT_FLAG = IEEE_FEATURES_TYPE(4), & Index: libgfortran/ieee/ieee_helper.c === --- libgfortran/ieee/ieee_helper.c (revision 267418) +++ libgfortran/ieee/ieee_helper.c (working copy) @@ -50,7 +50,8 @@ internal_proto(ieee_class_helper_16); enum { IEEE_OTHER_VALUE = 0, IEEE_SIGNALING_NAN, IEEE_QUIET_NAN, IEEE_NEGATIVE_INF, IEEE_NEGATIVE_NORMAL, IEEE_NEGATIVE_DENORMAL, IEEE_NEGATIVE_ZERO, IEEE_POSITIVE_ZERO, IEEE_POSITIVE_DENORMAL, - IEEE_POSITIVE_NORMAL, IEEE_POSITIVE_INF }; + IEEE_POSITIVE_NORMAL, IEEE_POSITIVE_INF, IEEE_SUBNORMAL, + IEEE_NEGATIVE_SUBNORMAL, IEEE_POSITIVE_SUBNORMAL };
[PATCH] PR fortran/81984 -- Placate the sanitizer
Tested on i586-*-freebsd. OK to commit? 2018-12-25 Steven G. Kargl PR fortran/81984 * intrinsics/string_intrinsics_inc.c: Placate the sanitizer. -- Steve Index: libgfortran/intrinsics/string_intrinsics_inc.c === --- libgfortran/intrinsics/string_intrinsics_inc.c (revision 267418) +++ libgfortran/intrinsics/string_intrinsics_inc.c (working copy) @@ -87,6 +87,14 @@ compare_string (gfc_charlen_type len1, const CHARTYPE gfc_charlen_type len; int res; + /* Placate the sanitizer. */ + if (!s1 && !s2) +return 0; + if (!s1) +return -1; + if (!s2) +return 1; + res = MEMCMP (s1, s2, ((len1 < len2) ? len1 : len2)); if (res != 0) return res;
[PATCH] PR fortran/81027 -- Issue error for assumed-shape array
Tested on i586-*-freebsd. OK to commit? 2018-12-25 Steven G. Kargl PR fortran/81027 * expr.c (gfc_check_init_expr): Issue an error message for an assumed-shape array as opposed to a deferred-shape array. 2018-12-25 Steven G. Kargl PR fortran/81027 * gfortran.dg/pr81027.f90: New test. -- Steve Index: gcc/fortran/expr.c === --- gcc/fortran/expr.c (revision 267418) +++ gcc/fortran/expr.c (working copy) @@ -2869,9 +2869,15 @@ gfc_check_init_expr (gfc_expr *e) break; case AS_DEFERRED: - gfc_error ("Deferred array %qs at %L is not permitted " - "in an initialization expression", - e->symtree->n.sym->name, &e->where); + if (!e->symtree->n.sym->attr.allocatable + && e->symtree->n.sym->attr.dummy) + gfc_error ("Assumed-shape array %qs at %L is not permitted " + "in an initialization expression", + e->symtree->n.sym->name, &e->where); + else + gfc_error ("Deferred array %qs at %L is not permitted " + "in an initialization expression", + e->symtree->n.sym->name, &e->where); break; case AS_EXPLICIT: Index: gcc/testsuite/gfortran.dg/pr81027.f90 === --- gcc/testsuite/gfortran.dg/pr81027.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr81027.f90 (working copy) @@ -0,0 +1,11 @@ +program badarray + implicit none + integer:: j(3) = [1,2,3] + call doubling(j) +contains + subroutine doubling( n) +integer,intent(in)::n(:) +integer::m = size(n) ! { dg-error "is not permitted in an" } +print *, m! { dg-error "has no IMPLICIT type" } + end subroutine doubling +end program badarray