aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCui, Lili <lili.cui@intel.com>2023-05-31 07:39:13 +0000
committerCui, Lili <lili.cui@intel.com>2023-05-31 07:51:14 +0000
commit80ee7d02e8db4893e104de02659fb71cc1dc81e9 (patch)
treef0d49af2476bd7bf3786cb1d062b60f99f5ce70d
parent5a98afec536ccc8e4530575edc5cf3420a4416b3 (diff)
downloadgcc-80ee7d02e8db4893e104de02659fb71cc1dc81e9.zip
gcc-80ee7d02e8db4893e104de02659fb71cc1dc81e9.tar.gz
gcc-80ee7d02e8db4893e104de02659fb71cc1dc81e9.tar.bz2
Fix ICE in rewrite_expr_tree_parallel
1. Limit the value of tree-reassoc-width to IntegerRange(0, 256). 2. Add width limit in rewrite_expr_tree_parallel. gcc/ChangeLog: PR tree-optimization/110038 * params.opt: Add a limit on tree-reassoc-width. * tree-ssa-reassoc.cc (rewrite_expr_tree_parallel): Add width limit. gcc/testsuite/ChangeLog: PR tree-optimization/110038 * gcc.dg/pr110038.c: New test.
-rw-r--r--gcc/params.opt2
-rw-r--r--gcc/testsuite/gcc.dg/pr110038.c10
-rw-r--r--gcc/tree-ssa-reassoc.cc4
3 files changed, 15 insertions, 1 deletions
diff --git a/gcc/params.opt b/gcc/params.opt
index 66f1c99..70cfb49 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -1091,7 +1091,7 @@ Common Joined UInteger Var(param_tracer_min_branch_ratio) Init(10) IntegerRange(
Stop reverse growth if the reverse probability of best edge is less than this threshold (in percent).
-param=tree-reassoc-width=
-Common Joined UInteger Var(param_tree_reassoc_width) Param Optimization
+Common Joined UInteger Var(param_tree_reassoc_width) IntegerRange(0, 256) Param Optimization
Set the maximum number of instructions executed in parallel in reassociated tree. If 0, use the target dependent heuristic.
-param=tsan-distinguish-volatile=
diff --git a/gcc/testsuite/gcc.dg/pr110038.c b/gcc/testsuite/gcc.dg/pr110038.c
new file mode 100644
index 0000000..0f578b1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr110038.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O --param=tree-reassoc-width=256" } */
+
+unsigned a, b;
+
+void
+foo (unsigned c)
+{
+ a += b + c + 1;
+}
diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc
index ad2f528..96c88ec 100644
--- a/gcc/tree-ssa-reassoc.cc
+++ b/gcc/tree-ssa-reassoc.cc
@@ -5510,6 +5510,10 @@ rewrite_expr_tree_parallel (gassign *stmt, int width, bool has_fma,
for (i = stmt_num - 2; i >= 0; i--)
stmts[i] = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmts[i+1]));
+ /* Width should not be larger than op_num / 2, since we can not create
+ more parallel dependency chains that exceeds such value. */
+ width = width <= op_num / 2 ? width : op_num / 2;
+
/* Build parallel dependency chain according to width. */
for (i = 0; i < width; i++)
{