[gcc(refs/users/aoliva/heads/testme)] verbose fold_truth_andor_1 - extra
Alexandre Oliva
aoliva@gcc.gnu.org
Thu Sep 17 11:31:55 GMT 2020
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;
More information about the Gcc-cvs
mailing list