and fix bugs - add-fp-model-options.patch: New file - enable-simd-math.patch: Enable simd math library in C and Fortran - fix-CTOR-vectorization.patch: New file - fix-range-set-by-vectorization-on-niter-IVs.patch: New file - medium-code-mode.patch: Fix bugs when used with fpic - optabs-Dont-use-scalar-conversions-for-vectors.patch: New file - PR92429-do-not-fold-when-updating.patch: New file - redundant-loop-elimination.patch: Fix some programming specifications - fix-ICE-in-vect.patch: New file - Fix-type-mismatch-in-SLPed-constructors.patch: New file - add-check-for-pressure-in-sche1.patch: New file - revert-moutline-atomics.patch: New file - fix-ICE-in-eliminate-stmt.patch: New file - revise-type-before-build-MULT.patch: New file - Simplify-X-C1-C2.patch: New file - gcc.spec: Add new patches
259 lines
10 KiB
Diff
259 lines
10 KiB
Diff
diff -Nurp a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
|
|
--- a/gcc/c-family/c-opts.c 2021-01-07 17:32:31.856000000 +0800
|
|
+++ b/gcc/c-family/c-opts.c 2021-01-07 17:05:02.524000000 +0800
|
|
@@ -783,6 +783,10 @@ c_common_post_options (const char **pfil
|
|
if (cpp_opts->deps.style == DEPS_NONE)
|
|
check_deps_environment_vars ();
|
|
|
|
+ if (flag_simdmath)
|
|
+ {
|
|
+ defer_opt (OPT_include, "simdmath.h");
|
|
+ }
|
|
handle_deferred_opts ();
|
|
|
|
sanitize_cpp_opts ();
|
|
diff -Nurp a/gcc/common.opt b/gcc/common.opt
|
|
--- a/gcc/common.opt 2021-01-07 17:30:43.912000000 +0800
|
|
+++ b/gcc/common.opt 2021-01-07 17:38:38.612000000 +0800
|
|
@@ -1935,6 +1935,10 @@ fmath-errno
|
|
Common Report Var(flag_errno_math) Init(1) Optimization SetByCombined
|
|
Set errno after built-in math functions.
|
|
|
|
+fsimdmath
|
|
+Common Report Var(flag_simdmath) Init(0) Optimization
|
|
+Enable auto-vectorize math functions for mathlib. This option will turn on -fno-math-errno and -fopenmp-simd.
|
|
+
|
|
fmax-errors=
|
|
Common Joined RejectNegative UInteger Var(flag_max_errors)
|
|
-fmax-errors=<number> Maximum number of errors to report.
|
|
diff -Nurp a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
|
|
--- a/gcc/config/aarch64/aarch64.c 2021-01-07 17:30:43.912000000 +0800
|
|
+++ b/gcc/config/aarch64/aarch64.c 2021-01-05 15:17:21.580000000 +0800
|
|
@@ -21588,8 +21588,12 @@ aarch64_simd_clone_compute_vecsize_and_s
|
|
elt_bits = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (base_type));
|
|
if (clonei->simdlen == 0)
|
|
{
|
|
- count = 2;
|
|
- vec_bits = (num == 0 ? 64 : 128);
|
|
+ /* Currently mathlib or sleef hasn't provide function for V2SF mode
|
|
+ simdclone of single precision functions. (e.g._ZCVnN2v_expf)
|
|
+ Therefore this mode is disabled by default to avoid link error.
|
|
+ Use -msimdmath-64 option to enable this mode. */
|
|
+ count = flag_simdmath_64 ? 2 : 1;
|
|
+ vec_bits = ((num == 0 && flag_simdmath_64) ? 64 : 128);
|
|
clonei->simdlen = vec_bits / elt_bits;
|
|
}
|
|
else
|
|
diff -Nurp a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
|
|
--- a/gcc/config/aarch64/aarch64.opt 2021-01-07 17:30:43.912000000 +0800
|
|
+++ b/gcc/config/aarch64/aarch64.opt 2021-01-05 15:17:21.448000000 +0800
|
|
@@ -197,6 +197,12 @@ precision of square root results to abou
|
|
single precision and to 32 bits for double precision.
|
|
If enabled, it implies -mlow-precision-recip-sqrt.
|
|
|
|
+msimdmath-64
|
|
+Target Var(flag_simdmath_64) Optimization
|
|
+Allow compiler to generate V2SF 64 bits simdclone of math functions,
|
|
+which is not currently supported in mathlib or sleef.
|
|
+Therefore this option is disabled by default.
|
|
+
|
|
mlow-precision-div
|
|
Target Var(flag_mlow_precision_div) Optimization
|
|
Enable the division approximation. Enabling this reduces
|
|
diff -Nurp a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
|
|
--- a/gcc/fortran/scanner.c 2021-01-07 17:31:59.264000000 +0800
|
|
+++ b/gcc/fortran/scanner.c 2021-01-07 17:05:28.776000000 +0800
|
|
@@ -2702,6 +2702,10 @@ gfc_new_file (void)
|
|
&& !load_file (flag_pre_include, NULL, false))
|
|
exit (FATAL_EXIT_CODE);
|
|
|
|
+ if (flag_simdmath
|
|
+ && !load_file ("simdmath_f.h", NULL, false))
|
|
+ exit (FATAL_EXIT_CODE);
|
|
+
|
|
if (gfc_cpp_enabled ())
|
|
{
|
|
result = gfc_cpp_preprocess (gfc_source_file);
|
|
diff -Nurp a/gcc/opts.c b/gcc/opts.c
|
|
--- a/gcc/opts.c 2021-01-07 17:30:57.740000000 +0800
|
|
+++ b/gcc/opts.c 2021-01-05 15:17:21.068000000 +0800
|
|
@@ -190,6 +190,7 @@ typedef char *char_p; /* For DEF_VEC_P.
|
|
static void handle_param (struct gcc_options *opts,
|
|
struct gcc_options *opts_set, location_t loc,
|
|
const char *carg);
|
|
+static void set_simdmath_flags (struct gcc_options *opts, int set);
|
|
static void set_debug_level (enum debug_info_type type, int extended,
|
|
const char *arg, struct gcc_options *opts,
|
|
struct gcc_options *opts_set,
|
|
@@ -2420,6 +2421,10 @@ common_handle_option (struct gcc_options
|
|
dc->min_margin_width = value;
|
|
break;
|
|
|
|
+ case OPT_fsimdmath:
|
|
+ set_simdmath_flags (opts, value);
|
|
+ break;
|
|
+
|
|
case OPT_fdump_:
|
|
/* Deferred. */
|
|
break;
|
|
@@ -2843,6 +2848,18 @@ handle_param (struct gcc_options *opts,
|
|
free (arg);
|
|
}
|
|
|
|
+/* The following routines are used to set -fno-math-errno and -fopenmp-simd
|
|
+ to enable vector mathlib. */
|
|
+static void
|
|
+set_simdmath_flags (struct gcc_options *opts, int set)
|
|
+{
|
|
+ if (set)
|
|
+ {
|
|
+ opts->x_flag_errno_math = 0;
|
|
+ opts->x_flag_openmp_simd = 1;
|
|
+ }
|
|
+}
|
|
+
|
|
/* Used to set the level of strict aliasing warnings in OPTS,
|
|
when no level is specified (i.e., when -Wstrict-aliasing, and not
|
|
-Wstrict-aliasing=level was given).
|
|
diff -Nurp a/libgomp/configure b/libgomp/configure
|
|
--- a/libgomp/configure 2021-01-07 17:40:08.216000000 +0800
|
|
+++ b/libgomp/configure 2021-01-07 16:29:45.628000000 +0800
|
|
@@ -17258,7 +17258,7 @@ fi
|
|
|
|
|
|
|
|
-ac_config_files="$ac_config_files omp.h omp_lib.h omp_lib.f90 libgomp_f.h"
|
|
+ac_config_files="$ac_config_files omp.h omp_lib.h simdmath.h simdmath_f.h omp_lib.f90 libgomp_f.h"
|
|
|
|
ac_config_files="$ac_config_files Makefile testsuite/Makefile libgomp.spec"
|
|
|
|
@@ -18426,6 +18426,8 @@ do
|
|
"gstdint.h") CONFIG_COMMANDS="$CONFIG_COMMANDS gstdint.h" ;;
|
|
"omp.h") CONFIG_FILES="$CONFIG_FILES omp.h" ;;
|
|
"omp_lib.h") CONFIG_FILES="$CONFIG_FILES omp_lib.h" ;;
|
|
+ "simdmath.h") CONFIG_FILES="$CONFIG_FILES simdmath.h" ;;
|
|
+ "simdmath_f.h") CONFIG_FILES="$CONFIG_FILES simdmath_f.h" ;;
|
|
"omp_lib.f90") CONFIG_FILES="$CONFIG_FILES omp_lib.f90" ;;
|
|
"libgomp_f.h") CONFIG_FILES="$CONFIG_FILES libgomp_f.h" ;;
|
|
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
|
|
diff -Nurp a/libgomp/configure.ac b/libgomp/configure.ac
|
|
--- a/libgomp/configure.ac 2021-01-07 17:40:08.216000000 +0800
|
|
+++ b/libgomp/configure.ac 2021-01-07 16:26:26.560000000 +0800
|
|
@@ -422,7 +422,7 @@ CFLAGS="$save_CFLAGS"
|
|
# Determine what GCC version number to use in filesystem paths.
|
|
GCC_BASE_VER
|
|
|
|
-AC_CONFIG_FILES(omp.h omp_lib.h omp_lib.f90 libgomp_f.h)
|
|
+AC_CONFIG_FILES(omp.h omp_lib.h simdmath.h simdmath_f.h omp_lib.f90 libgomp_f.h)
|
|
AC_CONFIG_FILES(Makefile testsuite/Makefile libgomp.spec)
|
|
AC_CONFIG_FILES([testsuite/libgomp-test-support.pt.exp:testsuite/libgomp-test-support.exp.in])
|
|
AC_OUTPUT
|
|
diff -Nurp a/libgomp/Makefile.am b/libgomp/Makefile.am
|
|
--- a/libgomp/Makefile.am 2021-01-07 17:40:08.168000000 +0800
|
|
+++ b/libgomp/Makefile.am 2021-01-07 16:27:39.776000000 +0800
|
|
@@ -74,9 +74,9 @@ libgomp_la_SOURCES += openacc.f90
|
|
endif
|
|
|
|
nodist_noinst_HEADERS = libgomp_f.h
|
|
-nodist_libsubinclude_HEADERS = omp.h openacc.h
|
|
+nodist_libsubinclude_HEADERS = omp.h openacc.h simdmath.h
|
|
if USE_FORTRAN
|
|
-nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod \
|
|
+nodist_finclude_HEADERS = omp_lib.h simdmath_f.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod \
|
|
openacc_lib.h openacc.f90 openacc.mod openacc_kinds.mod
|
|
endif
|
|
|
|
diff -Nurp a/libgomp/Makefile.in b/libgomp/Makefile.in
|
|
--- a/libgomp/Makefile.in 2021-01-07 17:40:08.208000000 +0800
|
|
+++ b/libgomp/Makefile.in 2021-01-07 16:50:28.820000000 +0800
|
|
@@ -145,7 +145,7 @@ am__CONFIG_DISTCLEAN_FILES = config.stat
|
|
configure.lineno config.status.lineno
|
|
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
|
|
CONFIG_HEADER = config.h
|
|
-CONFIG_CLEAN_FILES = omp.h omp_lib.h omp_lib.f90 libgomp_f.h \
|
|
+CONFIG_CLEAN_FILES = omp.h omp_lib.h simdmath.h simdmath_f.h omp_lib.f90 libgomp_f.h \
|
|
libgomp.spec
|
|
CONFIG_CLEAN_VPATH_FILES =
|
|
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
|
@@ -575,8 +575,8 @@ libgomp_la_SOURCES = alloc.c atomic.c ba
|
|
@PLUGIN_HSA_TRUE@libgomp_plugin_hsa_la_LIBADD = libgomp.la $(PLUGIN_HSA_LIBS)
|
|
@PLUGIN_HSA_TRUE@libgomp_plugin_hsa_la_LIBTOOLFLAGS = --tag=disable-static
|
|
nodist_noinst_HEADERS = libgomp_f.h
|
|
-nodist_libsubinclude_HEADERS = omp.h openacc.h
|
|
-@USE_FORTRAN_TRUE@nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod \
|
|
+nodist_libsubinclude_HEADERS = omp.h openacc.h simdmath.h
|
|
+@USE_FORTRAN_TRUE@nodist_finclude_HEADERS = omp_lib.h simdmath_f.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod \
|
|
@USE_FORTRAN_TRUE@ openacc_lib.h openacc.f90 openacc.mod openacc_kinds.mod
|
|
|
|
LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
|
|
@@ -668,6 +668,10 @@ omp.h: $(top_builddir)/config.status $(s
|
|
cd $(top_builddir) && $(SHELL) ./config.status $@
|
|
omp_lib.h: $(top_builddir)/config.status $(srcdir)/omp_lib.h.in
|
|
cd $(top_builddir) && $(SHELL) ./config.status $@
|
|
+simdmath_f.h: $(top_builddir)/config.status $(srcdir)/simdmath_f.h.in
|
|
+ cd $(top_builddir) && $(SHELL) ./config.status $@
|
|
+simdmath.h: $(top_builddir)/config.status $(srcdir)/simdmath.h.in
|
|
+ cd $(top_builddir) && $(SHELL) ./config.status $@
|
|
omp_lib.f90: $(top_builddir)/config.status $(srcdir)/omp_lib.f90.in
|
|
cd $(top_builddir) && $(SHELL) ./config.status $@
|
|
libgomp_f.h: $(top_builddir)/config.status $(srcdir)/libgomp_f.h.in
|
|
diff -Nurp a/libgomp/simdmath_f.h.in b/libgomp/simdmath_f.h.in
|
|
--- a/libgomp/simdmath_f.h.in 1970-01-01 08:00:00.000000000 +0800
|
|
+++ b/libgomp/simdmath_f.h.in 2021-01-07 16:13:23.196000000 +0800
|
|
@@ -0,0 +1,11 @@
|
|
+!GCC$ builtin (cos) attributes simd (notinbranch)
|
|
+!GCC$ builtin (cosf) attributes simd (notinbranch)
|
|
+!GCC$ builtin (sin) attributes simd (notinbranch)
|
|
+!GCC$ builtin (sinf) attributes simd (notinbranch)
|
|
+!GCC$ builtin (exp) attributes simd (notinbranch)
|
|
+!GCC$ builtin (expf) attributes simd (notinbranch)
|
|
+!GCC$ builtin (exp2f) attributes simd (notinbranch)
|
|
+!GCC$ builtin (log) attributes simd (notinbranch)
|
|
+!GCC$ builtin (logf) attributes simd (notinbranch)
|
|
+!GCC$ builtin (pow) attributes simd (notinbranch)
|
|
+!GCC$ builtin (powf) attributes simd (notinbranch)
|
|
diff -Nurp a/libgomp/simdmath.h.in b/libgomp/simdmath.h.in
|
|
--- a/libgomp/simdmath.h.in 1970-01-01 08:00:00.000000000 +0800
|
|
+++ b/libgomp/simdmath.h.in 2021-01-07 16:13:56.144000000 +0800
|
|
@@ -0,0 +1,40 @@
|
|
+#ifdef __cplusplus
|
|
+extern "C" {
|
|
+#endif
|
|
+
|
|
+#pragma omp declare simd simdlen(2) notinbranch
|
|
+double cos (double x);
|
|
+
|
|
+#pragma omp declare simd simdlen(4) notinbranch
|
|
+float cosf (float x);
|
|
+
|
|
+#pragma omp declare simd simdlen(2) notinbranch
|
|
+double sin (double x);
|
|
+
|
|
+#pragma omp declare simd simdlen(4) notinbranch
|
|
+float sinf (float x);
|
|
+
|
|
+#pragma omp declare simd simdlen(2) notinbranch
|
|
+double exp (double x);
|
|
+
|
|
+#pragma omp declare simd simdlen(4) notinbranch
|
|
+float expf (float x);
|
|
+
|
|
+#pragma omp declare simd simdlen(2) notinbranch
|
|
+double log (double x);
|
|
+
|
|
+#pragma omp declare simd simdlen(4) notinbranch
|
|
+float logf (float x);
|
|
+
|
|
+#pragma omp declare simd simdlen(2) notinbranch
|
|
+double pow (double x, double y);
|
|
+
|
|
+#pragma omp declare simd simdlen(4) notinbranch
|
|
+float powf (float x, float y);
|
|
+
|
|
+#pragma omp declare simd simdlen(4) notinbranch
|
|
+float exp2f (float x);
|
|
+
|
|
+#ifdef __cplusplus
|
|
+} // extern "C"
|
|
+#endif
|