public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-15 16:58 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-15 16:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1fc7c80b8c00083bd694d95880e8ebbaf868c57a

commit 1fc7c80b8c00083bd694d95880e8ebbaf868c57a
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e91e7778999..0b2c86f7340 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6227,6 +6227,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
   if (TREE_CODE_CLASS (lcode) != tcc_comparison
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
+      bool report = true;
+
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
 	 to try to merge individual operands, but avoiding double
@@ -6246,27 +6248,39 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 1), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    TREE_OPERAND (lhs, 0), result);
+	    {
+	      report = (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+			&& TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
+	      result = fold_build2_loc (loc, code, truth_type,
+					TREE_OPERAND (lhs, 0), result);
+	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 0), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (lhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (lhs, 1));
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
 	       && TREE_CODE (rhs) == code && TREE_TYPE (rhs) == truth_type)
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 0))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 1));
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 1))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 0));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 0));
 	}
+      else
+	result = NULL;
 
-      return 0;
+      if (report && result)
+	inform (loc, "extra merged %qT and %qT into %qT",
+		lhs, rhs, result);
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6709,6 +6723,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					 llr_arg, llr_const);
       result = build2_loc (loc, orig_code, truth_type,
 			   lll_result, llr_result);
+      inform (loc, "merged extra %qT and %qT into %qT", lhs, rhs, result);
     }
   else
     {


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-23 23:23 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-23 23:23 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e13b45f269f5cbb5cf7f9ad84f5abd86ccccd2d3

commit e13b45f269f5cbb5cf7f9ad84f5abd86ccccd2d3
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e39ab42049e..2def8bcff42 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6221,7 +6221,7 @@ compute_split_boundary_from_align (HOST_WIDE_INT align,
 
 static tree
 fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
-		    tree lhs, tree rhs, tree *separatep)
+		    tree lhs, tree rhs, tree *separatep, int recursed = 0)
 {
   /* If this is the "or" of two comparisons, we can do something if
      the comparisons are NE_EXPR.  If this is the "and", we can do something
@@ -6283,6 +6283,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
       tree separate = NULL;
+      bool report = true;
 
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
@@ -6305,8 +6306,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    TREE_OPERAND (lhs, 1), rhs,
 					    separatep
 					    ? separatep
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
+	      report = separatep || recursed > 1
+		|| (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+		    && TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
 	      /* We have combined the latter part of LHS with RHS.  If
 		 they were separate, the recursion already placed any
 		 remains of RHS in *SEPARATEP, otherwise they are all
@@ -6314,13 +6318,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 		 former part of LHS.  */
 	      result = fold_build2_loc (loc, code, truth_type,
 					TREE_OPERAND (lhs, 0), result);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    TREE_OPERAND (lhs, 0), rhs,
 					    separatep
 					    ? separatep
-					    : &separate)) != 0)
+					    : &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined the former part of LHS with RHS.  If
 		 they were separate, the recursive call will have
@@ -6334,7 +6338,6 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      if (separate)
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
@@ -6344,7 +6347,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    lhs, TREE_OPERAND (rhs, 0),
 					    separatep
 					    ? &separate
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the former part of RHS.  If
 		 they were separate, have any remnants of RHS placed
@@ -6362,11 +6365,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    lhs, TREE_OPERAND (rhs, 1),
-					    &separate)) != 0)
+					    &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the latter part of RHS.
 		 They're definitely not adjacent, so we get the
@@ -6385,11 +6388,22 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
+      else
+	result = NULL;
 
-      return 0;
+      if (report && result)
+	{
+	  if (separatep && *separatep)
+	    inform (loc, "extra merged %qE and %qE into %qE and %qE",
+		    lhs, rhs, result, *separatep);
+	  else
+	    inform (loc, "extra merged %qE and %qE into %qE",
+		    lhs, rhs, result);
+	}
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6844,6 +6858,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	  result = lll_result;
 	  *separatep = llr_result;
 	}
+
+      if (separatep && *separatep)
+	inform (loc, "merged extra %qE and %qE into %qE and %qE",
+		lhs, rhs, result, *separatep);
+      else
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
   else
     {
@@ -6862,6 +6883,10 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 
       result = build2_loc (loc, wanted_code, truth_type, result,
 			   const_binop (BIT_IOR_EXPR, l_const, r_const));
+
+      if (recursed > 1)
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
 
   return result;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-17 13:45 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-17 13:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0c1214b050de603306204d583c749ab9e1fc69ea

commit 0c1214b050de603306204d583c749ab9e1fc69ea
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index d65d4a79816..9c60becb789 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6177,7 +6177,7 @@ merge_truthop_with_opposite_arm (location_t loc, tree op, tree cmpop,
 
 static tree
 fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
-		    tree lhs, tree rhs, tree *separatep)
+		    tree lhs, tree rhs, tree *separatep, int recursed = 0)
 {
   /* If this is the "or" of two comparisons, we can do something if
      the comparisons are NE_EXPR.  If this is the "and", we can do something
@@ -6239,6 +6239,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
       tree separate = NULL;
+      bool report = true;
 
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
@@ -6261,8 +6262,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    TREE_OPERAND (lhs, 1), rhs,
 					    separatep
 					    ? separatep
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
+	      report = separatep || recursed > 1
+		|| (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+		    && TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
 	      /* We have combined the latter part of LHS with RHS.  If
 		 they were separate, the recursion already placed any
 		 remains of RHS in *SEPARATEP, otherwise they are all
@@ -6270,13 +6274,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 		 former part of LHS.  */
 	      result = fold_build2_loc (loc, code, truth_type,
 					TREE_OPERAND (lhs, 0), result);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    TREE_OPERAND (lhs, 0), rhs,
 					    separatep
 					    ? separatep
-					    : &separate)) != 0)
+					    : &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined the former part of LHS with RHS.  If
 		 they were separate, the recursive call will have
@@ -6290,7 +6294,6 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      if (separate)
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
@@ -6300,7 +6303,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    lhs, TREE_OPERAND (rhs, 0),
 					    separatep
 					    ? &separate
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the former part of RHS.  If
 		 they were separate, have any remnants of RHS placed
@@ -6318,11 +6321,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    lhs, TREE_OPERAND (rhs, 1),
-					    &separate)) != 0)
+					    &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the latter part of RHS.
 		 They're definitely not adjacent, so we get the
@@ -6341,11 +6344,22 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
+      else
+	result = NULL;
 
-      return 0;
+      if (report && result)
+	{
+	  if (separatep && *separatep)
+	    inform (loc, "extra merged %qE and %qE into %qE and %qE",
+		    lhs, rhs, result, *separatep);
+	  else
+	    inform (loc, "extra merged %qE and %qE into %qE",
+		    lhs, rhs, result);
+	}
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6818,6 +6832,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	  result = lll_result;
 	  *separatep = llr_result;
 	}
+
+      if (separatep && *separatep)
+	inform (loc, "merged extra %qE and %qE into %qE and %qE",
+		lhs, rhs, result, *separatep);
+      else
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
   else
     {
@@ -6836,6 +6857,10 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 
       result = build2_loc (loc, wanted_code, truth_type, result,
 			   const_binop (BIT_IOR_EXPR, l_const, r_const));
+
+      if (recursed > 1)
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
 
   return result;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-17 11:43 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-17 11:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0c1214b050de603306204d583c749ab9e1fc69ea

commit 0c1214b050de603306204d583c749ab9e1fc69ea
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index d65d4a79816..9c60becb789 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6177,7 +6177,7 @@ merge_truthop_with_opposite_arm (location_t loc, tree op, tree cmpop,
 
 static tree
 fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
-		    tree lhs, tree rhs, tree *separatep)
+		    tree lhs, tree rhs, tree *separatep, int recursed = 0)
 {
   /* If this is the "or" of two comparisons, we can do something if
      the comparisons are NE_EXPR.  If this is the "and", we can do something
@@ -6239,6 +6239,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
       tree separate = NULL;
+      bool report = true;
 
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
@@ -6261,8 +6262,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    TREE_OPERAND (lhs, 1), rhs,
 					    separatep
 					    ? separatep
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
+	      report = separatep || recursed > 1
+		|| (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+		    && TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
 	      /* We have combined the latter part of LHS with RHS.  If
 		 they were separate, the recursion already placed any
 		 remains of RHS in *SEPARATEP, otherwise they are all
@@ -6270,13 +6274,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 		 former part of LHS.  */
 	      result = fold_build2_loc (loc, code, truth_type,
 					TREE_OPERAND (lhs, 0), result);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    TREE_OPERAND (lhs, 0), rhs,
 					    separatep
 					    ? separatep
-					    : &separate)) != 0)
+					    : &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined the former part of LHS with RHS.  If
 		 they were separate, the recursive call will have
@@ -6290,7 +6294,6 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      if (separate)
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
@@ -6300,7 +6303,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    lhs, TREE_OPERAND (rhs, 0),
 					    separatep
 					    ? &separate
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the former part of RHS.  If
 		 they were separate, have any remnants of RHS placed
@@ -6318,11 +6321,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    lhs, TREE_OPERAND (rhs, 1),
-					    &separate)) != 0)
+					    &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the latter part of RHS.
 		 They're definitely not adjacent, so we get the
@@ -6341,11 +6344,22 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
+      else
+	result = NULL;
 
-      return 0;
+      if (report && result)
+	{
+	  if (separatep && *separatep)
+	    inform (loc, "extra merged %qE and %qE into %qE and %qE",
+		    lhs, rhs, result, *separatep);
+	  else
+	    inform (loc, "extra merged %qE and %qE into %qE",
+		    lhs, rhs, result);
+	}
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6818,6 +6832,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	  result = lll_result;
 	  *separatep = llr_result;
 	}
+
+      if (separatep && *separatep)
+	inform (loc, "merged extra %qE and %qE into %qE and %qE",
+		lhs, rhs, result, *separatep);
+      else
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
   else
     {
@@ -6836,6 +6857,10 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 
       result = build2_loc (loc, wanted_code, truth_type, result,
 			   const_binop (BIT_IOR_EXPR, l_const, r_const));
+
+      if (recursed > 1)
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
 
   return result;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-17 11:31 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-17 11:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6bfbcc69956fac3229262c5ded2d1c33f831b31b

commit 6bfbcc69956fac3229262c5ded2d1c33f831b31b
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 3f8f54a7f49..82a406f4037 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6177,7 +6177,7 @@ merge_truthop_with_opposite_arm (location_t loc, tree op, tree cmpop,
 
 static tree
 fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
-		    tree lhs, tree rhs, tree *separatep)
+		    tree lhs, tree rhs, tree *separatep, int recursed = 0)
 {
   /* If this is the "or" of two comparisons, we can do something if
      the comparisons are NE_EXPR.  If this is the "and", we can do something
@@ -6239,6 +6239,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
       tree separate = NULL;
+      bool report = true;
 
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
@@ -6261,8 +6262,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    TREE_OPERAND (lhs, 1), rhs,
 					    separatep
 					    ? separatep
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
+	      report = separatep || recursed > 1
+		|| (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+		    && TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
 	      /* We have combined the latter part of LHS with RHS.  If
 		 they were separate, the recursion already placed any
 		 remains of RHS in *SEPARATEP, otherwise they are all
@@ -6270,13 +6274,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 		 former part of LHS.  */
 	      result = fold_build2_loc (loc, code, truth_type,
 					TREE_OPERAND (lhs, 0), result);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    TREE_OPERAND (lhs, 0), rhs,
 					    separatep
 					    ? separatep
-					    : &separate)) != 0)
+					    : &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined the former part of LHS with RHS.  If
 		 they were separate, the recursive call will have
@@ -6290,7 +6294,6 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      if (separate)
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
@@ -6300,7 +6303,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    lhs, TREE_OPERAND (rhs, 0),
 					    separatep
 					    ? &separate
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the former part of RHS.  If
 		 they were separate, have any remnants of RHS placed
@@ -6318,11 +6321,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    lhs, TREE_OPERAND (rhs, 1),
-					    &separate)) != 0)
+					    &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the latter part of RHS.
 		 They're definitely not adjacent, so we get the
@@ -6341,11 +6344,22 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
+      else
+	result = NULL;
 
-      return 0;
+      if (report && result)
+	{
+	  if (separatep && *separatep)
+	    inform (loc, "extra merged %qE and %qE into %qE and %qE",
+		    lhs, rhs, result, *separatep);
+	  else
+	    inform (loc, "extra merged %qE and %qE into %qE",
+		    lhs, rhs, result);
+	}
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6818,6 +6832,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	  result = lll_result;
 	  *separatep = llr_result;
 	}
+
+      if (separatep && *separatep)
+	inform (loc, "merged extra %qE and %qE into %qE and %qE",
+		lhs, rhs, result, *separatep);
+      else
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
   else
     {
@@ -6836,6 +6857,10 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 
       result = build2_loc (loc, wanted_code, truth_type, result,
 			   const_binop (BIT_IOR_EXPR, l_const, r_const));
+
+      if (recursed > 1)
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
 
   return result;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-17  8:22 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-17  8:22 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:88bde4e82281723371fd02cc6fcc425e4c6439c6

commit 88bde4e82281723371fd02cc6fcc425e4c6439c6
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index c835327dac9..526687c647e 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6176,7 +6176,7 @@ merge_truthop_with_opposite_arm (location_t loc, tree op, tree cmpop,
 
 static tree
 fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
-		    tree lhs, tree rhs, tree *separatep)
+		    tree lhs, tree rhs, tree *separatep, int recursed = 0)
 {
   /* If this is the "or" of two comparisons, we can do something if
      the comparisons are NE_EXPR.  If this is the "and", we can do something
@@ -6238,6 +6238,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
       tree separate = NULL;
+      bool report = true;
 
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
@@ -6260,8 +6261,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    TREE_OPERAND (lhs, 1), rhs,
 					    separatep
 					    ? separatep
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
+	      report = separatep || recursed > 1
+		|| (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+		    && TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
 	      /* We have combined the latter part of LHS with RHS.  If
 		 they were separate, the recursion already placed any
 		 remains of RHS in *SEPARATEP, otherwise they are all
@@ -6269,13 +6273,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 		 former part of LHS.  */
 	      result = fold_build2_loc (loc, code, truth_type,
 					TREE_OPERAND (lhs, 0), result);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    TREE_OPERAND (lhs, 0), rhs,
 					    separatep
 					    ? separatep
-					    : &separate)) != 0)
+					    : &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined the former part of LHS with RHS.  If
 		 they were separate, the recursive call will have
@@ -6289,7 +6293,6 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      if (separate)
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
@@ -6299,7 +6302,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					    lhs, TREE_OPERAND (rhs, 0),
 					    separatep
 					    ? &separate
-					    : NULL)) != 0)
+					    : NULL, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the former part of RHS.  If
 		 they were separate, have any remnants of RHS placed
@@ -6317,11 +6320,11 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					    lhs, TREE_OPERAND (rhs, 1),
-					    &separate)) != 0)
+					    &separate, recursed + 1)) != 0)
 	    {
 	      /* We have combined LHS with the latter part of RHS.
 		 They're definitely not adjacent, so we get the
@@ -6340,11 +6343,22 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	      else
 		result = fold_build2_loc (loc, code, truth_type,
 					  result, separate);
-	      return result;
 	    }
 	}
+      else
+	result = NULL;
 
-      return 0;
+      if (report && result)
+	{
+	  if (separatep && *separatep)
+	    inform (loc, "extra merged %qE and %qE into %qE and %qE",
+		    lhs, rhs, result, *separatep);
+	  else
+	    inform (loc, "extra merged %qE and %qE into %qE",
+		    lhs, rhs, result);
+	}
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6817,6 +6831,13 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	  result = lll_result;
 	  *separatep = llr_result;
 	}
+
+      if (separatep && *separatep)
+	inform (loc, "merged extra %qE and %qE into %qE and %qE",
+		lhs, rhs, result, *separatep);
+      else
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
   else
     {
@@ -6835,6 +6856,10 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 
       result = build2_loc (loc, wanted_code, truth_type, result,
 			   const_binop (BIT_IOR_EXPR, l_const, r_const));
+
+      if (recursed > 1)
+	inform (loc, "merged extra %qE and %qE into %qE",
+		lhs, rhs, result);
     }
 
   return result;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-16 21:38 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-16 21:38 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5cbdb7518d0b8f2814d494ba783b0fddd581ca70

commit 5cbdb7518d0b8f2814d494ba783b0fddd581ca70
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e91e7778999..18d568819b3 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6227,6 +6227,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
   if (TREE_CODE_CLASS (lcode) != tcc_comparison
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
+      bool report = true;
+
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
 	 to try to merge individual operands, but avoiding double
@@ -6246,27 +6248,39 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 1), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    TREE_OPERAND (lhs, 0), result);
+	    {
+	      report = (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+			&& TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
+	      result = fold_build2_loc (loc, code, truth_type,
+					TREE_OPERAND (lhs, 0), result);
+	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 0), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (lhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (lhs, 1));
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
 	       && TREE_CODE (rhs) == code && TREE_TYPE (rhs) == truth_type)
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 0))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 1));
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 1))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 0));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 0));
 	}
+      else
+	result = NULL;
 
-      return 0;
+      if (report && result)
+	inform (loc, "extra merged %qE and %qE into %qE",
+		lhs, rhs, result);
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6709,6 +6723,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					 llr_arg, llr_const);
       result = build2_loc (loc, orig_code, truth_type,
 			   lll_result, llr_result);
+      inform (loc, "merged extra %qE and %qE into %qE", lhs, rhs, result);
     }
   else
     {


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-15 18:40 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-15 18:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bf566a4fd334bf91f5f76b59b11ff16357b3139d

commit bf566a4fd334bf91f5f76b59b11ff16357b3139d
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e91e7778999..18d568819b3 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6227,6 +6227,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
   if (TREE_CODE_CLASS (lcode) != tcc_comparison
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
+      bool report = true;
+
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
 	 to try to merge individual operands, but avoiding double
@@ -6246,27 +6248,39 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 1), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    TREE_OPERAND (lhs, 0), result);
+	    {
+	      report = (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+			&& TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
+	      result = fold_build2_loc (loc, code, truth_type,
+					TREE_OPERAND (lhs, 0), result);
+	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 0), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (lhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (lhs, 1));
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
 	       && TREE_CODE (rhs) == code && TREE_TYPE (rhs) == truth_type)
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 0))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 1));
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 1))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 0));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 0));
 	}
+      else
+	result = NULL;
 
-      return 0;
+      if (report && result)
+	inform (loc, "extra merged %qE and %qE into %qE",
+		lhs, rhs, result);
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6709,6 +6723,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					 llr_arg, llr_const);
       result = build2_loc (loc, orig_code, truth_type,
 			   lll_result, llr_result);
+      inform (loc, "merged extra %qE and %qE into %qE", lhs, rhs, result);
     }
   else
     {


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-15 18:16 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-15 18:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e091416b9750cd79c7dca8a9f7f25a3737d1ae07

commit e091416b9750cd79c7dca8a9f7f25a3737d1ae07
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e91e7778999..18d568819b3 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6227,6 +6227,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
   if (TREE_CODE_CLASS (lcode) != tcc_comparison
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
+      bool report = true;
+
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
 	 to try to merge individual operands, but avoiding double
@@ -6246,27 +6248,39 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 1), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    TREE_OPERAND (lhs, 0), result);
+	    {
+	      report = (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+			&& TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
+	      result = fold_build2_loc (loc, code, truth_type,
+					TREE_OPERAND (lhs, 0), result);
+	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 0), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (lhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (lhs, 1));
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
 	       && TREE_CODE (rhs) == code && TREE_TYPE (rhs) == truth_type)
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 0))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 1));
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 1))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 0));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 0));
 	}
+      else
+	result = NULL;
 
-      return 0;
+      if (report && result)
+	inform (loc, "extra merged %qE and %qE into %qE",
+		lhs, rhs, result);
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6709,6 +6723,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					 llr_arg, llr_const);
       result = build2_loc (loc, orig_code, truth_type,
 			   lll_result, llr_result);
+      inform (loc, "merged extra %qE and %qE into %qE", lhs, rhs, result);
     }
   else
     {


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
@ 2020-09-15 16:44 Alexandre Oliva
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Oliva @ 2020-09-15 16:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c69fa64469470c7841b60f61fe6f49bcfb721a83

commit c69fa64469470c7841b60f61fe6f49bcfb721a83
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Tue Sep 15 13:32:23 2020 -0300

    verbose fold_truth_andor_1 - extra

Diff:
---
 gcc/fold-const.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e91e7778999..b8e26c99fda 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6227,6 +6227,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
   if (TREE_CODE_CLASS (lcode) != tcc_comparison
       || TREE_CODE_CLASS (rcode) != tcc_comparison)
     {
+      bool report = true;
+
       /* Check for the possibility of merging component references.
 	 If any of our operands is another similar operation, recurse
 	 to try to merge individual operands, but avoiding double
@@ -6246,27 +6248,37 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 1), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    TREE_OPERAND (lhs, 0), result);
+	    {
+	      report = (TREE_CODE (TREE_OPERAND (lhs, 1)) == code
+			&& TREE_TYPE (TREE_OPERAND (lhs, 1)) == truth_type);
+	      result = fold_build2_loc (loc, code, truth_type,
+					TREE_OPERAND (lhs, 0), result);
+	    }
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type,
 					 TREE_OPERAND (lhs, 0), rhs)) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (lhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (lhs, 1));
 	}
       else if (TREE_CODE_CLASS (lcode) == tcc_comparison
 	       && TREE_CODE (rhs) == code && TREE_TYPE (rhs) == truth_type)
 	{
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 0))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 1));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 1));
+	  else
 	  if ((result = fold_truth_andor_1 (loc, code, truth_type, lhs,
 					 TREE_OPERAND (rhs, 1))) != 0)
-	    return fold_build2_loc (loc, code, truth_type,
-				    result, TREE_OPERAND (rhs, 0));
+	    result = fold_build2_loc (loc, code, truth_type,
+				      result, TREE_OPERAND (rhs, 0));
 	}
 
-      return 0;
+      if (report && result)
+	inform (loc, "extra merged %qT and %qT into %qT",
+		lhs, rhs, result);
+
+      return result;
     }
 
   ll_arg = TREE_OPERAND (lhs, 0);
@@ -6709,6 +6721,7 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type,
 					 llr_arg, llr_const);
       result = build2_loc (loc, orig_code, truth_type,
 			   lll_result, llr_result);
+      inform (loc, "merged extra %qT and %qT into %qT", lhs, rhs, result);
     }
   else
     {


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-09-23 23:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 16:58 [gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2020-09-23 23:23 Alexandre Oliva
2020-09-17 13:45 Alexandre Oliva
2020-09-17 11:43 Alexandre Oliva
2020-09-17 11:31 Alexandre Oliva
2020-09-17  8:22 Alexandre Oliva
2020-09-16 21:38 Alexandre Oliva
2020-09-15 18:40 Alexandre Oliva
2020-09-15 18:16 Alexandre Oliva
2020-09-15 16:44 Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).