[gcc(refs/vendors/ibm/heads/gcc-9)] backport: re PR tree-optimization/92644 (ICE in wide_int_to_tree_1, at tree.c:1530)

Peter Bergner bergner@gcc.gnu.org
Tue Feb 4 21:06:00 GMT 2020


https://gcc.gnu.org/g:3981df84e90b99dc720a76967666b09b193057e8

commit 3981df84e90b99dc720a76967666b09b193057e8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Dec 20 17:58:07 2019 +0100

    backport: re PR tree-optimization/92644 (ICE in wide_int_to_tree_1, at tree.c:1530)
    
    	Backported from mainline
    	2019-11-26  Jakub Jelinek  <jakub@redhat.com>
    
    	PR tree-optimization/92644
    	* tree-ssa-phiopt.c (minmax_replacement): Add INTEGRAL_TYPE_P check
    	next to INTEGER_CST checks.
    
    	* g++.dg/opt/pr92644.C: New test.
    
    From-SVN: r279652

Diff:
---
 gcc/ChangeLog                      | 6 ++++++
 gcc/testsuite/ChangeLog            | 5 +++++
 gcc/testsuite/g++.dg/opt/pr92644.C | 6 ++++++
 gcc/tree-ssa-phiopt.c              | 9 ++++++---
 4 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6803846..1a925ca 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,12 @@
 2019-12-20  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from mainline
+	2019-11-26  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/92644
+	* tree-ssa-phiopt.c (minmax_replacement): Add INTEGRAL_TYPE_P check
+	next to INTEGER_CST checks.
+
 	2019-11-23  Jakub Jelinek  <jakub@redhat.com>
 
 	PR target/92615
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f3d0452..a37e0b3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,11 @@
 2019-12-20  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from mainline
+	2019-11-26  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/92644
+	* g++.dg/opt/pr92644.C: New test.
+
 	2019-11-23  Jakub Jelinek  <jakub@redhat.com>
 
 	PR target/92615
diff --git a/gcc/testsuite/g++.dg/opt/pr92644.C b/gcc/testsuite/g++.dg/opt/pr92644.C
new file mode 100644
index 0000000..2f8a86f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr92644.C
@@ -0,0 +1,6 @@
+// PR tree-optimization/92644
+// { dg-do compile { target c++14 } }
+// { dg-options "-O2 -fno-early-inlining" }
+
+inline auto foo () { return nullptr; }
+int bar () { return foo () ? 1 : 0; }
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 8bf09bd..19b37b4 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1365,7 +1365,8 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
 
   /* Turn EQ/NE of extreme values to order comparisons.  */
   if ((cmp == NE_EXPR || cmp == EQ_EXPR)
-      && TREE_CODE (rhs) == INTEGER_CST)
+      && TREE_CODE (rhs) == INTEGER_CST
+      && INTEGRAL_TYPE_P (TREE_TYPE (rhs)))
     {
       if (wi::eq_p (wi::to_wide (rhs), wi::min_value (TREE_TYPE (rhs))))
 	{
@@ -1391,7 +1392,8 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
       larger = rhs;
       /* If we have smaller < CST it is equivalent to smaller <= CST-1.
 	 Likewise smaller <= CST is equivalent to smaller < CST+1.  */
-      if (TREE_CODE (larger) == INTEGER_CST)
+      if (TREE_CODE (larger) == INTEGER_CST
+	  && INTEGRAL_TYPE_P (TREE_TYPE (larger)))
 	{
 	  if (cmp == LT_EXPR)
 	    {
@@ -1419,7 +1421,8 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
       larger = gimple_cond_lhs (cond);
       /* If we have larger > CST it is equivalent to larger >= CST+1.
 	 Likewise larger >= CST is equivalent to larger > CST-1.  */
-      if (TREE_CODE (smaller) == INTEGER_CST)
+      if (TREE_CODE (smaller) == INTEGER_CST
+	  && INTEGRAL_TYPE_P (TREE_TYPE (smaller)))
 	{
 	  wi::overflow_type overflow;
 	  if (cmp == GT_EXPR)



More information about the Gcc-cvs mailing list