From 5985e21c0ee7717a55696b08f888c16d1f5b3872 Mon Sep 17 00:00:00 2001 From: Xiong Zhou Date: Mon, 18 Dec 2023 10:53:23 +0800 Subject: [PATCH] Sync patches from openeuler/gcc --- ...-the-problem-of-insufficient-CRC-tab.patch | 42 + ...ix-some-bugs-and-remove-variable-pre.patch | 924 ++++++++++++++++++ ...-change-def-selection-logic-in-noce_.patch | 30 + ...-Bugfix-Check-that-the-arithmetic-op.patch | 57 ++ gcc.spec | 16 +- 5 files changed, 1068 insertions(+), 1 deletion(-) create mode 100644 0163-Loop-CRC-Solving-the-problem-of-insufficient-CRC-tab.patch create mode 100644 0164-LLC-Allocation-Fix-some-bugs-and-remove-variable-pre.patch create mode 100644 0165-rtl-ifcvt-BugFix-change-def-selection-logic-in-noce_.patch create mode 100644 0166-perm-propagation-Bugfix-Check-that-the-arithmetic-op.patch diff --git a/0163-Loop-CRC-Solving-the-problem-of-insufficient-CRC-tab.patch b/0163-Loop-CRC-Solving-the-problem-of-insufficient-CRC-tab.patch new file mode 100644 index 0000000..48d4a57 --- /dev/null +++ b/0163-Loop-CRC-Solving-the-problem-of-insufficient-CRC-tab.patch @@ -0,0 +1,42 @@ +From 3281cef37191a800d4fcc916c0e9d5c7a43802a4 Mon Sep 17 00:00:00 2001 +From: XingYuShuai <1150775134@qq.com> +Date: Thu, 14 Dec 2023 20:11:35 +0800 +Subject: [PATCH 1/2] [Loop CRC] Solving the problem of insufficient CRC table + validation + +--- + gcc/tree-ssa-loop-crc.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/gcc/tree-ssa-loop-crc.c b/gcc/tree-ssa-loop-crc.c +index 9878363eb..2dd9e1e3b 100644 +--- a/gcc/tree-ssa-loop-crc.c ++++ b/gcc/tree-ssa-loop-crc.c +@@ -336,11 +336,14 @@ only_one_array_read (class loop *loop, tree &crc_table) + && TREE_CODE (gimple_assign_lhs (stmt)) == ARRAY_REF) + return false; + ++ /* Only one-dimensional integer arrays meet the condition. */ + if (gimple_code (stmt) == GIMPLE_ASSIGN +- && TREE_CODE (gimple_assign_rhs1 (stmt)) == ARRAY_REF) ++ && TREE_CODE (gimple_assign_rhs1 (stmt)) == ARRAY_REF ++ && TREE_CODE (TREE_OPERAND (gimple_assign_rhs1 (stmt), 0)) == VAR_DECL ++ && TREE_CODE (TREE_TYPE (gimple_assign_rhs1 (stmt))) == INTEGER_TYPE) + { + if (crc_table == NULL +- && gimple_assign_rhs1 (stmt)->base.readonly_flag) ++ && TREE_READONLY (gimple_assign_rhs1 (stmt))) + { + crc_table = gimple_assign_rhs1 (stmt); + crc_table_read_stmt = stmt; +@@ -438,7 +441,6 @@ match_crc_table (tree crc_table) + return true; + } + +- + /* Check the crc table. The loop should have only one data reference. + And match the data reference with the predefined array. */ + static bool +-- +2.33.0 + diff --git a/0164-LLC-Allocation-Fix-some-bugs-and-remove-variable-pre.patch b/0164-LLC-Allocation-Fix-some-bugs-and-remove-variable-pre.patch new file mode 100644 index 0000000..f1507fb --- /dev/null +++ b/0164-LLC-Allocation-Fix-some-bugs-and-remove-variable-pre.patch @@ -0,0 +1,924 @@ +From 1722afc51311a6bb0b892df50602f660c706162f Mon Sep 17 00:00:00 2001 +From: liuf9 +Date: Fri, 15 Dec 2023 11:25:48 +0800 +Subject: [PATCH 2/2] [LLC Allocation] Fix some bugs and remove variable + prefetch tool. After outer loop analysis, it is possible to get nested loops + for kernel candidates and this situation has conflicts with the early exiting + criterion for kernel filtering process and we restrict this criterion for + innermost loops only. We also fix some pass configuration bugs in common.opt + and params.opt. We remove variable prefetch tool due to the consideration of + unsafe inputs from users. + +--- + gcc/common.opt | 2 +- + gcc/params.opt | 24 +- + gcc/testsuite/gcc.dg/llc-allocate/llc-2.c | 2 +- + .../llc-allocate/llc-issue-builtin-prefetch.c | 48 ---- + .../llc-allocate/llc-tool-insertion-1.c | 48 ---- + .../llc-allocate/llc-tool-insertion-2.c | 48 ---- + .../llc-allocate/llc-tool-insertion-3.c | 48 ---- + .../llc-allocate/llc-tool-insertion-4.c | 47 --- + .../llc-allocate/llc-tool-insertion-5.c | 48 ---- + .../llc-allocate/llc-tool-insertion-6.c | 47 --- + .../llc-tool-insertion-7-null-var-name.c | 52 ---- + .../llc-tool-insertion-8-tmp-var-name.c | 54 ---- + gcc/tree-ssa-llc-allocate.c | 267 +----------------- + 13 files changed, 11 insertions(+), 724 deletions(-) + delete mode 100644 gcc/testsuite/gcc.dg/llc-allocate/llc-issue-builtin-prefetch.c + delete mode 100644 gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-1.c + delete mode 100644 gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-2.c + delete mode 100644 gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-3.c + delete mode 100644 gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-4.c + delete mode 100644 gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-5.c + delete mode 100644 gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-6.c + delete mode 100644 gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-7-null-var-name.c + delete mode 100644 gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-8-tmp-var-name.c + +diff --git a/gcc/common.opt b/gcc/common.opt +index 56ad9a378..a8a2264ee 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -2255,7 +2255,7 @@ Generate prefetch instructions, if available, for arrays in loops. The prefetch + level can control the optimize level to array prefetch. + + fllc-allocate +-Common Report Var(flag_llc_allocate) Init(-1) Optimization ++Common Report Var(flag_llc_allocate) Optimization + Generate LLC hint instructions. + + fipa-prefetch +diff --git a/gcc/params.opt b/gcc/params.opt +index 792ca5c35..ef7bea311 100644 +--- a/gcc/params.opt ++++ b/gcc/params.opt +@@ -1030,13 +1030,11 @@ Common Joined UInteger Var(param_mem_access_num) Init(3) Param Optimization + Memory access num. + + -param=prefetch-offset= +-Common Joined UInteger Var(param_prefetch_offset) Init(1024) +-IntegerRange(1, 999999) Param Optimization ++Common Joined UInteger Var(param_prefetch_offset) Init(1024) IntegerRange(1, 999999) Param Optimization + Prefetch Offset, which is usually a power of two due to cache line size. + + -param=branch-prob-threshold= +-Common Joined UInteger Var(param_branch_prob_threshold) Init(80) IntegerRange(50, 100) +-Param Optimization ++Common Joined UInteger Var(param_branch_prob_threshold) Init(80) IntegerRange(50, 100) Param Optimization + High Execution Rate Branch Threshold. + + -param=issue-topn= +@@ -1051,24 +1049,6 @@ Force issue the topn LLC mem_ref hint, without generating dynamic multi-branches + Common Joined UInteger Var(param_llc_capacity_per_core) Init(114) IntegerRange(0, 999999) Param + LLC capacity per core. + +--param=target-variables= +-Common Joined Var(param_target_variables) Init("") Param Optimization +---param=target-variables=[,,...] Target variables for prefetching, separated by comma, +-without space. The representation of a variable can be complex and containing space, please surround +-it by quotation marks and escape special characters in Linux. The input length should be no more +-than 512 characters. +- +--param=use-ref-group-index= +-Common Joined UInteger Var(param_use_ref_group_index) Init(0) IntegerRange(0, 1) Param Optimization +-Prefetch the target variables by their indices in sorted ref_groups, use together with parameter +-target-variables. +- +--param=mem-ref-index= +-Common Joined Var(param_mem_ref_index) Init("") Param Optimization +---param=mem-ref-index=[,,...] Prefetch the target variable at the memory reference +-location with the index of customized order, separated by comma, without space. The input length +-should be no more than 512 characters. +- + -param=filter-kernels= + Common Joined UInteger Var(param_filter_kernels) Init(1) IntegerRange(0, 1) Param + Allow LLC allocate pass to greedily filter kernels by traversing the corresponding basic blocks +diff --git a/gcc/testsuite/gcc.dg/llc-allocate/llc-2.c b/gcc/testsuite/gcc.dg/llc-allocate/llc-2.c +index 9f8a5c307..f8b1cc5c1 100644 +--- a/gcc/testsuite/gcc.dg/llc-allocate/llc-2.c ++++ b/gcc/testsuite/gcc.dg/llc-allocate/llc-2.c +@@ -45,7 +45,7 @@ main (int argc, char *argv[]) + /* { dg-final { scan-tree-dump-not "static_data_size:" "llc_allocate" } } */ + /* { dg-final { scan-tree-dump-times "\{ (?:\\d+\\(\\d+\\) ){1}\}" 2 "llc_allocate" } } */ + /* { dg-final { scan-tree-dump-not ", size: (?!(0\.000000))" "llc_allocate" } } */ +-/* { dg-final { scan-tree-dump-times ", size: 0\.000000" 8 "llc_allocate" } } */ ++/* { dg-final { scan-tree-dump-times ", size: 0\.000000" 6 "llc_allocate" } } */ + /* { dg-final { scan-tree-dump-times "\\d x_data \\(0.000000, 1, 0\\) : 3" 2 "llc_allocate" } } */ + /* { dg-final { scan-tree-dump-times "\\d A_j \\(0.000000, 1, 0\\) : 2" 2 "llc_allocate" } } */ + /* { dg-final { scan-tree-dump-times "\\d A_data \\(0.000000, 1, 0\\) : 2" 2 "llc_allocate" } } */ +diff --git a/gcc/testsuite/gcc.dg/llc-allocate/llc-issue-builtin-prefetch.c b/gcc/testsuite/gcc.dg/llc-allocate/llc-issue-builtin-prefetch.c +deleted file mode 100644 +index 2a58c501f..000000000 +--- a/gcc/testsuite/gcc.dg/llc-allocate/llc-issue-builtin-prefetch.c ++++ /dev/null +@@ -1,48 +0,0 @@ +-/* { dg-do compile { target { aarch64*-*-linux* } } } */ +-/* { dg-options "-O3 -march=armv8.2-a+sve -funroll-loops -ffast-math -static -fllc-allocate -fdump-tree-llc_allocate-details-lineno --param target-variables=uPtr" } */ +- +-#include +- +-#define N 131590 +-#define F 384477 +- +-double diagPtr[N]; +-double psiPtr[N]; +-double ApsiPtr[N]; +-int lPtr[F]; +-int uPtr[F]; +-double lowerPtr[F]; +-double upperPtr[F]; +- +-void +-AMUL (double *diagPtr, double *psiPtr, double *ApsiPtr, int *lPtr, +- int *uPtr, double *lowerPtr, double *upperPtr, int nCells, int nFaces) +-{ +- for (int cell=0; cell +- +-#define N 131590 +-#define F 384477 +- +-double diagPtr[N]; +-double psiPtr[N]; +-double ApsiPtr[N]; +-int lPtr[F]; +-int uPtr[F]; +-double lowerPtr[F]; +-double upperPtr[F]; +- +-void +-AMUL (double *diagPtr, double *psiPtr, double *ApsiPtr, int *lPtr, +- int *uPtr, double *lowerPtr, double *upperPtr, int nCells, int nFaces) +-{ +- for (int cell=0; cell +- +-#define N 131590 +-#define F 384477 +- +-double diagPtr[N]; +-double psiPtr[N]; +-double ApsiPtr[N]; +-int lPtr[F]; +-int uPtr[F]; +-double lowerPtr[F]; +-double upperPtr[F]; +- +-void +-AMUL (double *diagPtr, double *psiPtr, double *ApsiPtr, int *lPtr, +- int *uPtr, double *lowerPtr, double *upperPtr, int nCells, int nFaces) +-{ +- for (int cell=0; cell +- +-#define N 131590 +-#define F 384477 +- +-double diagPtr[N]; +-double psiPtr[N]; +-double ApsiPtr[N]; +-int lPtr[F]; +-int uPtr[F]; +-double lowerPtr[F]; +-double upperPtr[F]; +- +-void +-AMUL (double *diagPtr, double *psiPtr, double *ApsiPtr, int *lPtr, +- int *uPtr, double *lowerPtr, double *upperPtr, int nCells, int nFaces) +-{ +- for (int cell=0; cell +- +-#define N 131590 +-#define F 384477 +- +-double diagPtr[N]; +-double psiPtr[N]; +-double ApsiPtr[N]; +-int lPtr[F]; +-int uPtr[F]; +-double lowerPtr[F]; +-double upperPtr[F]; +- +-void +-AMUL (double *diagPtr, double *psiPtr, double *ApsiPtr, int *lPtr, +- int *uPtr, double *lowerPtr, double *upperPtr, int nCells, int nFaces) +-{ +- for (int cell=0; cell +- +-#define N 131590 +-#define F 384477 +- +-double diagPtr[N]; +-double psiPtr[N]; +-double ApsiPtr[N]; +-int lPtr[F]; +-int uPtr[F]; +-double lowerPtr[F]; +-double upperPtr[F]; +- +-void +-AMUL (double *diagPtr, double *psiPtr, double *ApsiPtr, int *lPtr, +- int *uPtr, double *lowerPtr, double *upperPtr, int nCells, int nFaces) +-{ +- for (int cell=0; cell +- +-#define N 131590 +-#define F 384477 +- +-double diagPtr[N]; +-double psiPtr[N]; +-double ApsiPtr[N]; +-int lPtr[F]; +-int uPtr[F]; +-double lowerPtr[F]; +-double upperPtr[F]; +- +-void +-AMUL (double *diagPtr, double *psiPtr, double *ApsiPtr, int *lPtr, +- int *uPtr, double *lowerPtr, double *upperPtr, int nCells, int nFaces) +-{ +- for (int cell=0; cellaux\"" } */ +- +-#include +- +-typedef struct stack_def +-{ +- int top; /* index to top stack element */ +- unsigned long reg_set; /* set of live registers */ +- unsigned char reg[128]; /* register - stack mapping */ +-} *stack; +- +-typedef struct block_info_def +-{ +- struct stack_def stack_in; /* Input stack configuration. */ +- struct stack_def stack_out; /* Output stack configuration. */ +- unsigned long out_reg_set; /* Stack regs live on output. */ +- int done; /* True if block already converted. */ +- int predecessors; /* Number of predecessors that need +- to be visited. */ +-} *block_info; +- +-typedef struct basic_block_def +-{ +- void *aux; +-} *basic_block; +- +-unsigned char +-convert_regs_exit (basic_block bb, int value_reg_low, int value_reg_high) +-{ +- stack output_stack; +- +- output_stack = &(((block_info) bb->aux)->stack_in); +- if (value_reg_low == -1) +- output_stack->top = -1; +- else +- { +- int reg; +- output_stack->top = value_reg_high - value_reg_low; +- for (reg = value_reg_low; reg <= value_reg_high; ++reg) +- { +- (output_stack->reg + 16)[value_reg_high - reg] = reg; +- output_stack->reg_set |= (unsigned long) 1 << reg; +- } +- } +- return output_stack->reg[0]; +-} +- +-/* { dg-final { scan-tree-dump-not "Unrecognizable variable name" +- "llc_allocate" } } */ +-/* { dg-final { scan-tree-dump-not "runtime issue" "llc_allocate" } } */ +-/* { dg-final { scan-tree-dump-not "static issue" "llc_allocate" } } */ +diff --git a/gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-8-tmp-var-name.c b/gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-8-tmp-var-name.c +deleted file mode 100644 +index 09a525ce1..000000000 +--- a/gcc/testsuite/gcc.dg/llc-allocate/llc-tool-insertion-8-tmp-var-name.c ++++ /dev/null +@@ -1,54 +0,0 @@ +-/* { dg-do compile { target { aarch64*-*-linux* } } } */ +-/* { dg-options "-O3 -c -fllc-allocate -fdump-tree-llc_allocate-details-lineno --param filter-kernels=0 --param target-variables=tmp_var_0" } */ +- +-#include +- +-typedef struct stack_def +-{ +- int top; /* index to top stack element */ +- unsigned long reg_set; /* set of live registers */ +- unsigned char reg[128]; /* register - stack mapping */ +-} *stack; +- +-typedef struct block_info_def +-{ +- struct stack_def stack_in; /* Input stack configuration. */ +- struct stack_def stack_out; /* Output stack configuration. */ +- unsigned long out_reg_set; /* Stack regs live on output. */ +- int done; /* True if block already converted. */ +- int predecessors; /* Number of predecessors that need +- to be visited. */ +-} *block_info; +- +-typedef struct basic_block_def +-{ +- void *aux; +-} *basic_block; +- +-unsigned char +-convert_regs_exit (basic_block bb, int value_reg_low, int value_reg_high) +-{ +- stack output_stack; +- +- output_stack = &(((block_info) bb->aux)->stack_in); +- if (value_reg_low == -1) +- output_stack->top = -1; +- else +- { +- int reg; +- output_stack->top = value_reg_high - value_reg_low; +- for (reg = value_reg_low; reg <= value_reg_high; ++reg) +- { +- (output_stack->reg + 16)[value_reg_high - reg] = reg; +- output_stack->reg_set |= (unsigned long) 1 << reg; +- } +- } +- return output_stack->reg[0]; +-} +- +-/* { dg-final { scan-tree-dump-not "Unrecognizable variable name" +- "llc_allocate" } } */ +-/* { dg-final { scan-tree-dump-times "NOTICE: Prefetching target variable \"" +- " bb_16(D)->aux \"" 1 "llc_allocate" } } */ +-/* { dg-final { scan-tree-dump-not "runtime issue" "llc_allocate" } } */ +-/* { dg-final { scan-tree-dump-times "static issue" 1 "llc_allocate" } } */ +diff --git a/gcc/tree-ssa-llc-allocate.c b/gcc/tree-ssa-llc-allocate.c +index 890f66e54..fa8979401 100644 +--- a/gcc/tree-ssa-llc-allocate.c ++++ b/gcc/tree-ssa-llc-allocate.c +@@ -23,7 +23,6 @@ along with GCC; see the file COPYING3. If not see + #define INCLUDE_VECTOR + #define INCLUDE_LIST + #define INCLUDE_ALGORITHM +-#define INCLUDE_STRING + #include "system.h" + #include "coretypes.h" + #include "backend.h" +@@ -1866,7 +1865,10 @@ filter_and_sort_kernels (vector &sorted_kernels, + list walked_header_bb; /* Used to record nested loops. */ + + for (unsigned i = 0; i < kernels.size (); ++i) +- end_bb.insert (kernels[i]->header); ++ { ++ if (kernels[i]->inner == NULL) ++ end_bb.insert (kernels[i]->header); ++ } + + dump_loop_headers ("kernels", kernels); + +@@ -2380,30 +2382,6 @@ issue_builtin_prefetch (data_ref &mem_ref) + update_ssa (TODO_update_ssa_only_virtuals); + } + +-/* Retrieve memory reference at the specific index. */ +- +-data_ref +-get_data_ref_at_idx (ref_group &var_ref_group) +-{ +- unsigned int mem_ref_size = static_cast( +- var_ref_group.ref_scores.size ()); +- if (strlen (param_mem_ref_index) == 0) +- return var_ref_group.first_use; +- else +- { +- /* Insert prefetch hint at highly-likely-used location with the given +- index. */ +- if (var_ref_group.mem_ref_index >= mem_ref_size) +- { +- if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "WARNING: The target data_ref index is out " +- "of range. Use top index instead!\n"); +- return var_ref_group.ref_scores[0].d_ref; +- } +- return var_ref_group.ref_scores[var_ref_group.mem_ref_index].d_ref; +- } +-} +- + /* Static form insertion and issue instruction. We may check the + determination of the ARM SVE architecture before SVE hint insertion. */ + +@@ -2415,7 +2393,7 @@ static_issue (vector &ref_groups, int num_issue_var) + + for (int i = 0; i < num_issue_var; ++i) + { +- data_ref mem_ref = get_data_ref_at_idx (ref_groups[i]); ++ data_ref mem_ref = ref_groups[i].first_use; + if (mem_ref.vectorize_p) + { + enum internal_fn ifn_code = gimple_call_internal_fn +@@ -2591,10 +2569,7 @@ issue_llc_hint (vector &ref_groups) + } + if (param_force_issue) + { +- if (strlen (param_target_variables) > 0) +- static_issue (ref_groups, static_cast(ref_groups.size ())); +- else +- static_issue (ref_groups, num_issue_var); ++ static_issue (ref_groups, num_issue_var); + return; + } + calc_type topn_calc_type = STATIC_CALC; +@@ -2626,224 +2601,6 @@ issue_llc_hint (vector &ref_groups) + } + + /* ==================== phase entry ==================== */ +-/* Check whether a string can be converted to an unsigned integer. */ +- +-bool is_unsigned_int (const string &s) +-{ +- if (s.empty () || s.size () > PREFETCH_TOOL_NUM_MAX_LEN) +- return false; +- +- for (unsigned int i = 0; i < s.size (); ++i) +- { +- if (s[i] < '0' || s[i] > '9') +- return false; +- } +- return true; +-} +- +-/* Parse a substring separated by comma. If the substring is valid and +- non-empty, store it as a parsed element. */ +- +-bool +-parse_string_helper (const string &substr, vector& str_elts, +- bool check_unsigned, size_t start, size_t end) +-{ +- if (substr == "" && dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "WARNING: The input string from %lu to %lu is " +- "empty.\n", start, end); +- else if (check_unsigned && !is_unsigned_int (substr)) +- { +- if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "ERROR: not an unsigned integer: %s\n", +- substr.c_str ()); +- str_elts.clear (); +- return false; +- } +- else +- str_elts.push_back (substr); +- return true; +-} +- +-/* Parse a user input string, separated by comma. */ +- +-void +-parse_string (const string &s, vector& str_elts, +- bool check_unsigned = false) +-{ +- string delim = ","; +- size_t start = 0; +- size_t end = s.find (delim); +- string substr = s.substr (start, end - start); +- while (end != string::npos) +- { +- if (!parse_string_helper (substr, str_elts, check_unsigned, start, end)) +- return; +- start = end + delim.size (); +- end = s.find (delim, start); +- substr = s.substr (start, end - start); +- } +- parse_string_helper (substr, str_elts, check_unsigned, start, end); +-} +- +-/* Parse user input of target variables and memory indices and create a map +- that assigns a target variable to a memory index. */ +- +-void +-parse_param_inputs (map &var2mem_idx) +-{ +- /* The user input length should have an input length limit. */ +- if ((strlen (param_target_variables) >= PREFETCH_TOOL_INPUT_MAX_LEN +- || strlen (param_mem_ref_index) >= PREFETCH_TOOL_INPUT_MAX_LEN) +- && dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "INVALID INPUT: The user inputs for target variables " +- "and/or memory reference indices are too long for parsing.\n"); +- +- vector var_names; +- string target_variables = param_target_variables; +- if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "Start parsing target variables:\n"); +- if (param_use_ref_group_index) +- parse_string (target_variables, var_names, true); +- else +- parse_string (target_variables, var_names, false); +- if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "Finish parsing target variables.\n\n"); +- +- vector var_mem_indices; +- string mem_indices = param_mem_ref_index; +- if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "Start parsing memory reference indices:\n"); +- parse_string (mem_indices, var_mem_indices, true); +- if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "Finish parsing memory reference indices.\n\n"); +- +- /* Construct a map of var_name: var_mem_index. */ +- if (var_names.size () > 0) +- { +- if (var_mem_indices.size () < var_names.size ()) +- { +- if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "WARNING: The number of provided memory " +- "reference indices is less than that of target " +- "variables.\nUse the top index for all variables " +- "instead.\n"); +- for (string& var_name : var_names) +- var2mem_idx[var_name] = 0; +- } +- else +- { +- if (var_mem_indices.size () > var_names.size () +- && dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "WARNING: The number of target variables is " +- "less than that of memory reference indices.\n"); +- for (unsigned int i = 0; i < var_names.size (); ++i) +- { +- var2mem_idx[var_names[i]] = static_cast( +- atoi (var_mem_indices[i].c_str ())); +- } +- } +- } +-} +- +-/* Filter reference groups by only selecting target variables from the user +- input. There are two options for prefetching target variables: +- 1. Specify variable name parsed by the pass, which you can double-check at +- "sorted ref_groups" section in the dump file. +- 2. Specify variable rank exhibited at "sorted ref_groups" section in the +- dump file. +-*/ +- +-void +-prefetch_variables (const vector& ref_groups, +- vector& reduced_ref_groups) +-{ +- map ref_group2mem_idx; +- +- map var2mem_idx; /* externally defined. */ +- parse_param_inputs (var2mem_idx); +- +- if (param_use_ref_group_index) +- { +- /* Use ref_group index at "sorted ref_groups" section to specify +- variable. */ +- /* Collect the variables in "reduced_ref_group" only if their indices +- show up at "sorted ref_groups" section. */ +- for (const pair &var_mem_idx : var2mem_idx) +- { +- unsigned int var_idx = static_cast(atoi ( +- var_mem_idx.first.c_str ())); +- if (var_idx < ref_groups.size ()) +- ref_group2mem_idx[var_idx] = var_mem_idx.second; +- else if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "WARNING: The index \"%u\" does not show " +- "up in the ref_groups.\n", var_idx); +- } +- } +- else +- { +- /* Use variable name shown up at "sorted ref_groups" section to specify +- variable: +- var2ref_group_idx + var2mem_idx -> ref_group2mem_idx. */ +- /* Create a map that assigns the variable name to its corresponding +- ref_group index. */ +- map var2ref_group_idx; /* internally detected. */ +- for (unsigned int i = 0; i < ref_groups.size (); ++i) +- { +- const ref_group &curr_ref_group = ref_groups[i]; +- const int UINT_MAX_DIGIT = 10; +- /* Unrecognizable variable name related to ref_group. */ +- if (!get_name (curr_ref_group.var)) +- { +- /* If the variable name does not have a string representation, +- we can rename it by "tmp_var_" + . */ +- char group_idx[UINT_MAX_DIGIT]; +- sprintf (group_idx, "%u", i); +- string tmp_var_name = "tmp_var_" + std::string (group_idx); +- fprintf (dump_file, "Unrecognizable variable name at ref_group " +- "index %u.\nThe tree expression for variable is: ", i); +- print_generic_expr (dump_file, curr_ref_group.var, TDF_SLIM); +- fprintf (dump_file, "\n"); +- var2ref_group_idx[tmp_var_name] = i; +- } +- else +- var2ref_group_idx[std::string (get_name (curr_ref_group.var))] = i; +- } +- /* Collect the variables in "reduced_ref_group" only if they show up in +- the ref_groups. */ +- for (const pair &var_mem_idx : var2mem_idx) +- { +- if (var2ref_group_idx.count (var_mem_idx.first)) +- { +- unsigned int ref_group_idx = var2ref_group_idx[var_mem_idx.first]; +- ref_group2mem_idx[ref_group_idx] = var_mem_idx.second; +- } +- else if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "WARNING: Target variable \" %s \" does " +- "not show up in the ref_groups. Check whether it needs " +- "temporary variable name.\n", +- var_mem_idx.first.c_str ()); +- } +- } +- +- for (const pair &ref_group_mem_idx : +- ref_group2mem_idx) +- { +- ref_group curr_ref_group = ref_groups[ref_group_mem_idx.first]; +- curr_ref_group.mem_ref_index = ref_group_mem_idx.second; +- reduced_ref_groups.push_back (curr_ref_group); +- if (dump_file && (dump_flags & TDF_DETAILS)) +- { +- fprintf (dump_file, "\nNOTICE: Prefetching target variable \" "); +- print_generic_expr (dump_file, curr_ref_group.var, TDF_SLIM); +- fprintf (dump_file, " \" at ref_group index %u and memory location " +- "index %u.\n", ref_group_mem_idx.first, +- ref_group_mem_idx.second); +- } +- } +- if (dump_file && (dump_flags & TDF_DETAILS)) +- fprintf (dump_file, "\n\n"); +-} +- + + /* The LLC intelligent allocation consists of 6 steps. */ + +@@ -2869,17 +2626,7 @@ llc_allocate (void) + if (!record_and_sort_ref_groups (ref_groups, sorted_kernels, kernels_refs)) + return; + +- if (strlen (param_target_variables) > 0) +- { +- /* If "param_target_variables" is not empty, we will issue parsed target +- variables compulsorily. */ +- param_force_issue = true; +- vector reduced_ref_groups; +- prefetch_variables (ref_groups, reduced_ref_groups); +- issue_llc_hint (reduced_ref_groups); +- } +- else +- issue_llc_hint (ref_groups); ++ issue_llc_hint (ref_groups); + } + + /* Check whether the function is an operator reloading function. */ +-- +2.33.0 + diff --git a/0165-rtl-ifcvt-BugFix-change-def-selection-logic-in-noce_.patch b/0165-rtl-ifcvt-BugFix-change-def-selection-logic-in-noce_.patch new file mode 100644 index 0000000..909b9d5 --- /dev/null +++ b/0165-rtl-ifcvt-BugFix-change-def-selection-logic-in-noce_.patch @@ -0,0 +1,30 @@ +From 506eb1ff5ca27cd8d741ddf1894a32645919f773 Mon Sep 17 00:00:00 2001 +From: vchernon +Date: Sun, 17 Dec 2023 01:47:02 +0800 +Subject: [PATCH] [rtl-ifcvt][BugFix] change def selection logic in noce_arith + +--- + gcc/ifcvt.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c +index 04086c560..a55ac16f3 100644 +--- a/gcc/ifcvt.c ++++ b/gcc/ifcvt.c +@@ -1985,11 +1985,10 @@ bbs_ok_for_cmove_arith (basic_block bb_a, + + if (!sset_a) + goto end_cmove_arith_check_and_fail; +- if (a_insn == last_a) +- continue; + /* Record all registers that BB_A sets. */ + FOR_EACH_INSN_DEF (def, a_insn) +- bitmap_set_bit (bba_sets, DF_REF_REGNO (def)); ++ if (!(to_rename && DF_REF_REG (def) == to_rename && a_insn == last_a)) ++ bitmap_set_bit (bba_sets, DF_REF_REGNO (def)); + } + + bitmap_and (intersections, df_get_live_in (bb_b), bba_sets); +-- +2.33.0 + diff --git a/0166-perm-propagation-Bugfix-Check-that-the-arithmetic-op.patch b/0166-perm-propagation-Bugfix-Check-that-the-arithmetic-op.patch new file mode 100644 index 0000000..9d4b534 --- /dev/null +++ b/0166-perm-propagation-Bugfix-Check-that-the-arithmetic-op.patch @@ -0,0 +1,57 @@ +From 43b6906c94ce6a683d325b8789267b7ee2d9bf15 Mon Sep 17 00:00:00 2001 +From: Diachkov Ilia WX1215920 +Date: Sat, 16 Dec 2023 11:56:30 +0300 +Subject: [PATCH] [perm propagation][Bugfix] Check that the arithmetic + operations follow each other + +--- + gcc/tree-ssa-forwprop.c | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c +index 92ef5d036..d5e9ca9bb 100644 +--- a/gcc/tree-ssa-forwprop.c ++++ b/gcc/tree-ssa-forwprop.c +@@ -2662,14 +2662,28 @@ check_def_use_order (vec &first_stmts, vec &second_stmts) + /* Check similarity of stmts in the block of arithmetic operations. */ + + static bool +-check_arithmetic_block (vec &initial_perm_stmts, unsigned nstmts) ++check_arithmetic_block (auto_vec &all_arith_stmts, ++ vec &initial_perm_stmts, unsigned nstmts) + { + auto_vec next_stmts (nstmts); + auto_vec prev_stmts (nstmts); ++ hash_set arith_stmt_set; + + enum tree_code code; + unsigned i; +- gimple *stmt_it; ++ gimple *stmt_it, *last_stmt = all_arith_stmts[all_arith_stmts.length () - 1]; ++ ++ /* Check that the arithmetic operations follow each other. */ ++ all_arith_stmts.qsort (gimple_uid_cmp); ++ FOR_EACH_VEC_ELT (all_arith_stmts, i, stmt_it) ++ arith_stmt_set.add (stmt_it); ++ ++ gimple_stmt_iterator gsi; ++ for (gsi = gsi_for_stmt (all_arith_stmts[0]); gsi_stmt (gsi) != last_stmt; ++ gsi_next (&gsi)) ++ if (!arith_stmt_set.contains (gsi_stmt (gsi))) ++ return false; ++ + FOR_EACH_VEC_ELT (initial_perm_stmts, i, stmt_it) + prev_stmts.quick_push (stmt_it); + +@@ -2778,7 +2792,7 @@ analyze_perm_fwprop (tree type, unsigned HOST_WIDE_INT nelts, + } + + /* Check that all results has the same arithmetic patterns. */ +- if (!check_arithmetic_block (final_arith_stmts, nelts)) ++ if (!check_arithmetic_block (all_arith_stmts, final_arith_stmts, nelts)) + return false; + + if (final_arith_stmts.length () < nelts) +-- +2.33.0 + diff --git a/gcc.spec b/gcc.spec index 3e5bebf..c40e569 100644 --- a/gcc.spec +++ b/gcc.spec @@ -61,7 +61,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: 44 +Release: 45 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD URL: https://gcc.gnu.org @@ -270,6 +270,10 @@ Patch159: 0159-Implement-AES-pattern-matching.patch Patch160: 0160-AES-Add-lost-files.patch Patch161: 0161-Fix-lost-ftree-fold-phiopt-option-in-tests.patch Patch162: 0162-rtl-ifcvt-free-dominance-info-before-cleanup_cfg.patch +Patch163: 0163-Loop-CRC-Solving-the-problem-of-insufficient-CRC-tab.patch +Patch164: 0164-LLC-Allocation-Fix-some-bugs-and-remove-variable-pre.patch +Patch165: 0165-rtl-ifcvt-BugFix-change-def-selection-logic-in-noce_.patch +Patch166: 0166-perm-propagation-Bugfix-Check-that-the-arithmetic-op.patch %global gcc_target_platform %{_arch}-linux-gnu @@ -885,6 +889,10 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch160 -p1 %patch161 -p1 %patch162 -p1 +%patch163 -p1 +%patch164 -p1 +%patch165 -p1 +%patch166 -p1 %build @@ -2909,6 +2917,12 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Mon Dec 18 2023 Xiong Zhou - 10.3.1-45 +- Type:Sync +- ID:NA +- SUG:NA +- DESC: Sync patches from openeuler/gcc + * Fri Dec 15 2023 Xiong Zhou - 10.3.1-44 - Type:Sync - ID:NA -- Gitee