diff --git a/SOURCES/gcc8-Improve-non-loop-disambiguation.patch b/SOURCES/gcc8-Improve-non-loop-disambiguation.patch new file mode 100644 index 0000000000000000000000000000000000000000..73cd3a70aeab4e4e8ebaeafbaba25e6b85b60590 --- /dev/null +++ b/SOURCES/gcc8-Improve-non-loop-disambiguation.patch @@ -0,0 +1,81 @@ +diff --git a/gcc/common.opt b/gcc/common.opt +index d320d90d7..824210c83 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -2870,6 +2870,10 @@ ftree-loop-vectorize + Common Report Var(flag_tree_loop_vectorize) Optimization EnabledBy(ftree-vectorize) + Enable loop vectorization on trees. + ++falias-analysis-expand-ssa ++Common Var(flag_alias_analysis_expand_ssa) Init(0) ++Enable expanded SSA name analysis during alias analysis. ++ + ftree-slp-vectorize + Common Report Var(flag_tree_slp_vectorize) Optimization EnabledBy(ftree-vectorize) + Enable basic block vectorization (SLP) on trees. +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index e70ecaf9c..d79309fc9 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -7729,6 +7729,7 @@ override_Fortran_optimize_options (struct gcc_options *opts) + opts->x_flag_ipa_pta = 1; + opts->x_flag_reorder_blocks_and_partition = 1; + opts->x_flag_reorder_blocks = 1; ++ opts->x_flag_alias_analysis_expand_ssa = 1; + } + + /* Reset the optimize option. +diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr106019.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr106019.c +new file mode 100644 +index 000000000..5ff8a8a62 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr106019.c +@@ -0,0 +1,16 @@ ++/* { dg-do compile } */ ++/* { dg-additional-options "-falias-analysis-expand-ssa" } */ ++ ++void f(double *p, long i) ++{ ++ p[i+0] += 1; ++ p[i+1] += 1; ++} ++void g(double *p, long i) ++{ ++ double *q = p + i; ++ q[0] += 1; ++ q[1] += 1; ++} ++ ++/* { dg-final { scan-tree-dump-not "can't determine dependence" slp2 } } */ +diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c +index c90e862fb..6ec33ebfa 100644 +--- a/gcc/tree-data-ref.c ++++ b/gcc/tree-data-ref.c +@@ -2242,6 +2242,27 @@ dr_may_alias_p (const struct data_reference *a, const struct data_reference *b, + disambiguation. */ + if (!loop_nest) + { ++ if (flag_alias_analysis_expand_ssa) ++ { ++ tree tree_size_a = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (a))); ++ tree tree_size_b = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (b))); ++ ++ if (DR_BASE_ADDRESS (a) ++ && DR_BASE_ADDRESS (b) ++ && operand_equal_p (DR_BASE_ADDRESS (a), DR_BASE_ADDRESS (b)) ++ && operand_equal_p (DR_OFFSET (a), DR_OFFSET (b)) ++ && poly_int_tree_p (tree_size_a) ++ && poly_int_tree_p (tree_size_b) ++ && !ranges_maybe_overlap_p (wi::to_widest (DR_INIT (a)), ++ wi::to_widest (tree_size_a), ++ wi::to_widest (DR_INIT (b)), ++ wi::to_widest (tree_size_b))) ++ { ++ gcc_assert (integer_zerop (DR_STEP (a)) ++ && integer_zerop (DR_STEP (b))); ++ return false; ++ } ++ } + aff_tree off1, off2; + poly_widest_int size1, size2; + get_inner_reference_aff (DR_REF (a), &off1, &size1); diff --git a/SOURCES/gcc8-fix-model-param-reading-bug.patch b/SOURCES/gcc8-fix-model-param-reading-bug.patch new file mode 100644 index 0000000000000000000000000000000000000000..2f5e43fc5dbda8dda16b37972e0af4c6adce8549 --- /dev/null +++ b/SOURCES/gcc8-fix-model-param-reading-bug.patch @@ -0,0 +1,39 @@ +diff --git a/gcc/ai-optimizer.c b/gcc/ai-optimizer.c +index 9edd935a7..0100577fc 100644 +--- a/gcc/ai-optimizer.c ++++ b/gcc/ai-optimizer.c +@@ -284,14 +284,15 @@ static int + graph_infer (int argc1, const char **argv1, const char *mops, + int argc2, int64_t *argv2) + { +- char gcc_exec_prefix[512]; ++ const int prefix_buff_len = 512; ++ char gcc_exec_prefix[prefix_buff_len] = {0}; + ssize_t len = readlink ("/proc/self/exe", gcc_exec_prefix, + sizeof (gcc_exec_prefix) - 1); + if (len == -1) + return 0; + +- char native_file[512]; +- strncpy (native_file, gcc_exec_prefix, sizeof (native_file) - 1); ++ char native_file[prefix_buff_len] = {0}; ++ strncpy (native_file, gcc_exec_prefix, len); + const char *target = "bin/gcc"; + const char *target_cc1 = "cc1"; + const char *target_gpp = "bin/g++"; +@@ -329,6 +330,8 @@ graph_infer (int argc1, const char **argv1, const char *mops, + strlen (native_file) - 1); + } + } ++ else ++ return 0; + if (access (native_file, F_OK) == 0) + fill_node (native_file); + else +@@ -421,4 +424,4 @@ get_optimize_decision_from_optimizer (int argc, const char **argv, + { + putenv ("AI_INFER_LEVEL=1"); + } +-} +\ No newline at end of file ++} diff --git a/SPECS/gcc.spec b/SPECS/gcc.spec index 47562b85ebc61b424b44d697d73b7c027bd42202..82b70740d5b3acd8ce7cb184cc97b12dcc96ec80 100644 --- a/SPECS/gcc.spec +++ b/SPECS/gcc.spec @@ -105,7 +105,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}%{?dist}.ap.3 +Release: %{gcc_release}%{?dist}.ap.4 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD @@ -333,6 +333,8 @@ Patch5008: gcc8-struct-dfc-optimization.patch Patch5009: gcc8-array-dse-optimization.patch Patch5010: gcc8-support-for-hip12.patch Patch5011: gcc8-fix-build-error.patch +Patch5012: gcc8-Improve-non-loop-disambiguation.patch +Patch5013: gcc8-fix-model-param-reading-bug.patch # On ARM EABI systems, we do want -gnueabi to be part of the # target triple. @@ -972,6 +974,8 @@ so that there cannot be any synchronization problems. %patch5009 -p1 -b .array-dse-optimization~ %patch5010 -p1 -b .support-for-hip12~ %patch5011 -p1 -b .fix-build-error~ +%patch5012 -p1 -b .Improve-non-loop~ +%patch5013 -p1 -b .fix-model-param~ cd nvptx-tools-%{nvptx_tools_gitrev} %patch2000 -p1 -b .nvptx-tools-no-ptxas~ @@ -2437,6 +2441,7 @@ fi %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}/lto1 %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}/lto-wrapper %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}/liblto_plugin.so* +%{_prefix}/libexec/gcc/optimizer.fdata %ifarch aarch64 %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major}/libbolt_plugin.so* %endif @@ -3385,6 +3390,10 @@ fi %{ANNOBIN_GCC_PLUGIN_DIR}/gcc-annobin.so.0.0.0 %changelog +* Fri Jul 18 2025 cao-jiaju <272503532@qq.com> - 8.5.0-26.ap.4 +- Add improve non-loop disambiguation optimization +- Fix model param reading bug + * Thu Jul 3 2025 huzife <634763349@qq.com> - 8.5.0-26.ap.3 - Add array-dse and dfc optimization - Add support for hip12 pipeline