1 Star 0 Fork 132

wangding16/src-gcc

forked from src-openEuler/gcc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0092-phiopt2-Add-option-to-control-the-simplify.patch 7.24 KB
一键复制 编辑 原始数据 按行查看 历史
From bc6537191e91c854cc6bee3319290d7a86768957 Mon Sep 17 00:00:00 2001
From: zhongyunde <zhongyunde@huawei.com>
Date: Wed, 10 May 2023 18:39:47 +0800
Subject: [PATCH 2/2] [phiopt2] Add option to control the simplify
The phiopt is brought in https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=c4574d23cb07340918793a5a98ae7bb2988b3791
But may be also has some bug fixed by later commit, so disable it default temporary.
This optimization is expected to enable after we update the gcc'base to gcc12's release version.
---
gcc/common.opt | 4 ++++
gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/bool-1.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/bool-2.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr18134.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr21829.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c | 4 ++--
gcc/tree-ssa-phiopt.c | 3 +++
13 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index be7bfee60..5ad2def18 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2781,6 +2781,10 @@ ftree-store-ccp
Common Ignore
Does nothing. Preserved for backward compatibility.
+ftree-fold-phiopt
+Common Report Var(flag_fold_phiopt) Init(0) Optimization
+Attempt to simply the phi node with ssa form.
+
ftree-ch
Common Report Var(flag_tree_ch) Optimization
Enable loop header copying on trees.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c
index 364ce6a69..b04316d55 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-phiopt2-details" } */
+/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-phiopt2-details" } */
int t( int i)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bool-1.c b/gcc/testsuite/gcc.dg/tree-ssa/bool-1.c
index 401357f2f..892654108 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/bool-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/bool-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
int f(_Bool x)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bool-2.c b/gcc/testsuite/gcc.dg/tree-ssa/bool-2.c
index add9cca1e..5ead90f06 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/bool-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/bool-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
int f(_Bool x)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c
index 4c190e6af..7b678fafc 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
int nem1_phi (unsigned long a) { return a ? -1 : 0; }
int eqm1_phi (unsigned long a) { return a ? 0 : -1; }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c
index fd3706666..23b679644 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c
@@ -1,6 +1,6 @@
/* PR tree-optimization/97690 */
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-phiopt2" } */
+/* { dg-options "-O2 -ftree-fold-phiopt -fdump-tree-phiopt2" } */
int foo (_Bool d) { return d ? 2 : 0; }
int bar (_Bool d) { return d ? 1 : 0; }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c
index 3bdb85609..4efd9afc4 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
_Bool t();
_Bool t1();
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
index 18ecbd52a..60dcc6733 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
int g(int,int);
int f(int t, int c)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c
index 98c596b6a..aaa71a317 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-optimized -fdump-tree-phiopt2" } */
+/* { dg-options "-O -ftree-fold-phiopt -fdump-tree-optimized -fdump-tree-phiopt2" } */
int g(int,int);
int f(int t, int c)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c b/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c
index cd40ab2c1..efb1907cf 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
int foo (int a)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21829.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21829.c
index 8f5ae5127..8c8ada905 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21829.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21829.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -ftree-fold-phiopt -fdump-tree-optimized" } */
int test(int v)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
index a2770e5e8..88c13806a 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
@@ -1,9 +1,9 @@
/* PR tree-optimization/96928 */
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-phiopt2" } */
+/* { dg-options "-O2 -ftree-fold-phiopt -fdump-tree-phiopt2 -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times " = a_\[0-9]*\\\(D\\\) >> " 5 "phiopt2" } } */
/* { dg-final { scan-tree-dump-times " = ~c_\[0-9]*\\\(D\\\);" 1 "phiopt2" } } */
-/* { dg-final { scan-tree-dump-times " = ~" 1 "phiopt2" } } */
+/* { dg-final { scan-tree-dump-times " = ~" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times " = \[abc_0-9\\\(\\\)D]* \\\^ " 5 "phiopt2" } } */
/* { dg-final { scan-tree-dump-not "a < 0" "phiopt2" } } */
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 51a2d3684..b7012932f 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -839,6 +839,9 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
tree result;
gimple *stmt_to_move = NULL;
+ if (!flag_fold_phiopt)
+ return false;
+
/* Special case A ? B : B as this will always simplify to B. */
if (operand_equal_for_phi_arg_p (arg0, arg1))
return false;
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangding16/src-gcc.git
git@gitee.com:wangding16/src-gcc.git
wangding16
src-gcc
src-gcc
master

搜索帮助