]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix a typo in two_value_replacement function
authorLi Jia He <helijia@linux.ibm.com>
Wed, 15 May 2019 05:20:02 +0000 (05:20 +0000)
committerLi Jia He <helijia@gcc.gnu.org>
Wed, 15 May 2019 05:20:02 +0000 (05:20 +0000)
2019-05-15  Li Jia He  <helijia@linux.ibm.com>

Backport from mainline.
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: r271198

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr37508.c
gcc/testsuite/gcc.dg/tree-ssa/pr88676-2.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.c

index 6ebf816873c6ed8fcddf1dc1e5b04bc34f24e9ba..20a80ecab263544464a3e37ff117ad8cbdc1af29 100644 (file)
@@ -1,3 +1,11 @@
+2019-05-15  Li Jia He  <helijia@linux.ibm.com>
+
+       Backport from mainline.
+       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-14  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index 3733de40a7d49b951b30f8865cfa0569c174e064..1f6da940d34cdf08e543054b901f084900052f11 100644 (file)
@@ -1,3 +1,12 @@
+2019-05-15  Li Jia He  <helijia@linux.ibm.com>
+
+       Backport from mainline.
+       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-14  Iain Sandoe  <iain@sandoe.co.uk>
 
        Backport from mainline.
index 2ba09afe4819e622e34798dcbe935a184fe39e77..a6def045de40b725b5e44f2c0c6c6ed97e9c61c2 100644 (file)
@@ -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 (file)
index 0000000..0e61636
--- /dev/null
@@ -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" { target le } } } */
+
+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;
+}
+
index 219791ea4ba57c234e96ead69dec3ea00d025ad5..90674a2f3c49a852b208daf032b2934c343c45be 100644 (file)
@@ -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))