diff options
author | Li Jia He <helijia@linux.ibm.com> | 2019-05-07 05:39:01 +0000 |
---|---|---|
committer | Li Jia He <helijia@gcc.gnu.org> | 2019-05-07 05:39:01 +0000 |
commit | b65307e96ef90ce24de6b33af765977c2bc88d17 (patch) | |
tree | 33713d11b52a1900863265277464bd4401aa551e | |
parent | caa3bffa03aedb538809aa36cab8e9441fe79e55 (diff) | |
download | gcc-b65307e96ef90ce24de6b33af765977c2bc88d17.zip gcc-b65307e96ef90ce24de6b33af765977c2bc88d17.tar.gz gcc-b65307e96ef90ce24de6b33af765977c2bc88d17.tar.bz2 |
Fix a typo in two_value_replacement function
GCC revision 267634 implemented two_value_replacement function.
However, a typo occurred during the parameter check, which caused
us to miss some optimizations.
The intent of the code might be to check that the input parameters
are const int and their difference is one. However, when I read
the code, I found that it is wrong to detect whether an input data
plus one is equal to itself. This could be a typo.
2019-05-07 Li Jia He <helijia@linux.ibm.com>
* tree-ssa-phiopt.c (two_value_replacement): Fix a typo in parameter
detection.
* gcc.dg/tree-ssa/pr37508.c: Add the no-ssa-phiopt option to skip phi
optimization.
* gcc.dg/tree-ssa/pr88676-2.c: New testcase.
From-SVN: r270934
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr37508.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr88676-2.c | 30 | ||||
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 2 |
5 files changed, 45 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 41b158c..028f992 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-05-07 Li Jia He <helijia@linux.ibm.com> + + * tree-ssa-phiopt.c (two_value_replacement): Fix a typo in parameter + detection. + 2019-05-06 Segher Boessenkool <segher@kernel.crashing.org> * config/rs6000/rs6000.md (FIRST_ALTIVEC_REGNO, LAST_ALTIVEC_REGNO) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 662b419..28157d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-05-07 Li Jia He <helijia@linux.ibm.com> + + * gcc.dg/tree-ssa/pr37508.c: Add the no-ssa-phiopt option to skip phi + optimization. + * gcc.dg/tree-ssa/pr88676-2.c: New testcase. + 2019-05-06 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/90290 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c b/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c index 2ba09af..a6def04 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fno-tree-fre -fdump-tree-vrp1" } */ +/* { dg-options "-O2 -fno-ssa-phiopt -fno-tree-fre -fdump-tree-vrp1" } */ struct foo1 { int i:1; @@ -22,7 +22,7 @@ int test2 (struct foo2 *x) { if (x->i == 0) return 1; - else if (x->i == -1) /* This test is already folded to false by ccp1. */ + else if (x->i == -1) /* This test is already optimized by ccp1 or phiopt1. */ return 1; return 0; } @@ -31,7 +31,7 @@ int test3 (struct foo1 *x) { if (x->i == 0) return 1; - else if (x->i == 1) /* This test is already folded to false by fold. */ + else if (x->i == 1) /* This test is already optimized by ccp1 or phiopt1. */ return 1; return 0; } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr88676-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr88676-2.c new file mode 100644 index 0000000..9ad2a50 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr88676-2.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/88676 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt1" } */ +/* { dg-final { scan-tree-dump-not " = PHI <" "phiopt1" } } */ + +struct foo1 { + int i:1; +}; +struct foo2 { + unsigned i:1; +}; + +int test1 (struct foo1 *x) +{ + if (x->i == 0) + return 1; + else if (x->i == 1) + return 1; + return 0; +} + +int test2 (struct foo2 *x) +{ + if (x->i == 0) + return 1; + else if (x->i == -1) + return 1; + return 0; +} + diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 219791e..90674a2 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -602,7 +602,7 @@ two_value_replacement (basic_block cond_bb, basic_block middle_bb, || TREE_CODE (arg1) != INTEGER_CST || (tree_int_cst_lt (arg0, arg1) ? wi::to_widest (arg0) + 1 != wi::to_widest (arg1) - : wi::to_widest (arg1) + 1 != wi::to_widest (arg1))) + : wi::to_widest (arg1) + 1 != wi::to_widest (arg0))) return false; if (!empty_block_p (middle_bb)) |