This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: cleanup for conversion exprs code patterns (14/16)
- From: tomby at atrey dot karlin dot mff dot cuni dot cz (Tomas Bily)
- To: gcc-patches at gcc dot gnu dot org
- Cc: tomby at ucw dot cz,tbily at suse dot cz
- Date: Mon, 31 Mar 2008 16:50:18 +0200 (CEST)
- Subject: [PATCH]: cleanup for conversion exprs code patterns (14/16)
Hi,
this series of patches is doing small cleanup in using conversion
expressions code patterns. There is a lot of duplicate code patterns
for conversion expressions (CONVERT_EXPR, NOP_EXPR, NON_LVALUE_EXPR)
that can be substituted by macro. Patterns are:
(TREE_CODE (EXP) == NOP_EXPR || TREE_CODE (EXP) == CONVERT_EXPR)
-> TEST_CONVERT_NOPS_P(EXP)
(TREE_CODE (EXP) == NOP_EXPR || TREE_CODE (EXP) == CONVERT_EXPR
|| TREE_CODE (EXP) == NON_LVALUE_EXPR)
-> TEST_NOPS_P(EXP)
case NOP_EXPR: case CONVERT_EXPR
-> CASE_CONVERT_NOPS
case NOP_EXPR: case CONVERT_EXPR: case NON_LVALUE_EXPR
-> CASE_NOPS
while (TREE_CODE (EXP) == NOP_EXPR
|| TREE_CODE (EXP) == CONVERT_EXPR
|| TREE_CODE (EXP) == NON_LVALUE_EXPR)
(EXP) = TREE_OPERAND (EXP, 0)
-> STRIP_NOPS_UNSAFE(EXP)
-> means replaced by
Patch 1: Add new macros (TEST_CONVERT_NOPS_P(EXP), TEST_NOPS_P(EXP),
CASE_CONVERT_NOPS, CASE_NOPS, STRIP_NOPS_UNSAFE(EXP)).
Patch 2-4: Add support of TEST_CONVERT_NOPS_P.
Patch 5-8: Add support of TEST_NOPS_P.
Patch 9-11: Add support of CASE_CONVERT_NOPS.
Patch 12-13: Add support of CASE_NOPS.
Patch 14-16: Add support of STRIP_NOPS_UNSAFE.
Bootstraped and tested on x86_64 x86_64 GNU/Linux.
Ok?
Greetings
Tomas
Patch 14
Changelog:
2008-03-13 Tomas Bily <tbily@suse.cz>
* tree-ssa-threadedge.c (simplify_control_stmt_condition): Use STRIP_NOPS_UNSAFE.
* expr.c (is_aligning_offset): Likewise.
* tree.c (really_constant_p): Likewise.
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 132974)
+++ gcc/tree.c (working copy)
@@ -1605,10 +1605,7 @@ int
really_constant_p (const_tree exp)
{
/* This is not quite the same as STRIP_NOPS. It does more. */
- while (TREE_CODE (exp) == NOP_EXPR
- || TREE_CODE (exp) == CONVERT_EXPR
- || TREE_CODE (exp) == NON_LVALUE_EXPR)
- exp = TREE_OPERAND (exp, 0);
+ STRIP_NOPS_UNSAFE (exp);
return TREE_CONSTANT (exp);
}
Index: gcc/expr.c
===================================================================
--- gcc/expr.c (revision 132974)
+++ gcc/expr.c (working copy)
@@ -9444,10 +9442,7 @@ static int
is_aligning_offset (const_tree offset, const_tree exp)
{
/* Strip off any conversions. */
- while (TREE_CODE (offset) == NON_LVALUE_EXPR
- || TREE_CODE (offset) == NOP_EXPR
- || TREE_CODE (offset) == CONVERT_EXPR)
- offset = TREE_OPERAND (offset, 0);
+ STRIP_NOPS_UNSAFE (offset);
/* We must now have a BIT_AND_EXPR with a constant that is one less than
power of 2 and which is larger than BIGGEST_ALIGNMENT. */
@@ -9461,19 +9456,13 @@ is_aligning_offset (const_tree offset, c
/* Look at the first operand of BIT_AND_EXPR and strip any conversion.
It must be NEGATE_EXPR. Then strip any more conversions. */
offset = TREE_OPERAND (offset, 0);
- while (TREE_CODE (offset) == NON_LVALUE_EXPR
- || TREE_CODE (offset) == NOP_EXPR
- || TREE_CODE (offset) == CONVERT_EXPR)
- offset = TREE_OPERAND (offset, 0);
+ STRIP_NOPS_UNSAFE (offset);
if (TREE_CODE (offset) != NEGATE_EXPR)
return 0;
offset = TREE_OPERAND (offset, 0);
- while (TREE_CODE (offset) == NON_LVALUE_EXPR
- || TREE_CODE (offset) == NOP_EXPR
- || TREE_CODE (offset) == CONVERT_EXPR)
- offset = TREE_OPERAND (offset, 0);
+ STRIP_NOPS_UNSAFE (offset);
/* This must now be the address of EXP. */
return TREE_CODE (offset) == ADDR_EXPR && TREE_OPERAND (offset, 0) == exp;
Index: gcc/tree-ssa-threadedge.c
===================================================================
--- gcc/tree-ssa-threadedge.c (revision 132974)
+++ gcc/tree-ssa-threadedge.c (working copy)
@@ -428,10 +428,7 @@ simplify_control_stmt_condition (edge e,
fold_defer_overflow_warnings ();
cached_lhs = fold (COND_EXPR_COND (dummy_cond));
- while (TREE_CODE (cached_lhs) == NOP_EXPR
- || TREE_CODE (cached_lhs) == CONVERT_EXPR
- || TREE_CODE (cached_lhs) == NON_LVALUE_EXPR)
- cached_lhs = TREE_OPERAND (cached_lhs, 0);
+ STRIP_NOPS_UNSAFE (cached_lhs);
fold_undefer_overflow_warnings (is_gimple_min_invariant (cached_lhs),
stmt, WARN_STRICT_OVERFLOW_CONDITIONAL);