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 (2/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:49:17 +0200 (CEST)
- Subject: [PATCH]: cleanup for conversion exprs code patterns (2/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 2
Changelog:
2008-03-13 Tomas Bily <tbily@suse.cz>
* convert.c (strip_float_extensions): Use TEST_CONVERT_NOPS_P.
* config/alpha/alpha.c (va_list_skip_additions): Likewise.
* c-common.c (c_alignof_expr, check_function_arguments_recurse):
Likewise.
* tree-ssa-forwprop.c (can_propagate_from)
(forward_propagate_addr_expr_1, forward_propagate_addr_expr)
(forward_propagate_comparison)
(tree_ssa_forward_propagate_single_use_vars): Likewise.
* cfgexpand.c (discover_nonconstant_array_refs_r): Likewise.
* tree-ssa-phiopt.c (conditional_replacement): Likewise
* gimplify.c (gimplify_conversion): Likewise.
(gimplify_conversion): Likewise.
* c-typeck.c (build_indirect_ref): Likewise.
(build_function_call): Likewise.
(pointer_diff): Likewise.
(build_compound_expr): Likewise.
* tree-vect-analyze.c (vect_determine_vectorization_factor): Likewise.
* matrix-reorg.c (may_flatten_matrices_1, get_inner_of_cast_expr):
Likewise.
* tree-ssa-ifcombine.c (recognize_single_bit_test): Likewise.
* tree-ssa-alias.c (is_escape_site): Likewise.
* tree-stdarg.c (va_list_counter_bump): Likewise.
(check_va_list_escapes): Likewise.
* tree-ssa-loop-ivopts.c (determine_base_object): Likewise.
(determine_common_wider_type): Likewise.
* tree-ssa-sccvn.c (simplify_unary_expression): Likewise.
* tree-gimple.c (is_gimple_cast): Likewise.
* objc-act.c (objc_finish_message_expr): Likewise.
* fold-const.c (fold_sign_changed_comparison): Likewise.
(fold_unary): Likewise.
(fold_comparison): Likewise.
(fold_binary): Likewise.
* tree-ssa-alias-warnings.c (find_alias_site_helper): Likewise.
(already_warned_in_frontend_p): Likewise
* tree.c (get_unwidened): Likewise.
* tree-ssa-loop-niter.c (expand_simple_operations): Likewise.
* tree-ssa-loop-im.c (rewrite_bittest): Likewise.
Index: gcc/tree-ssa-loop-im.c
===================================================================
--- gcc/tree-ssa-loop-im.c (revision 132974)
+++ gcc/tree-ssa-loop-im.c (working copy)
@@ -646,8 +646,7 @@ rewrite_bittest (block_stmt_iterator *bs
/* There is a conversion in between possibly inserted by fold. */
t = GIMPLE_STMT_OPERAND (stmt1, 1);
- if (TREE_CODE (t) == NOP_EXPR
- || TREE_CODE (t) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (t))
{
t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) != SSA_NAME
Index: gcc/tree-ssa-loop-niter.c
===================================================================
--- gcc/tree-ssa-loop-niter.c (revision 132974)
+++ gcc/tree-ssa-loop-niter.c (working copy)
@@ -1437,8 +1437,7 @@ expand_simple_operations (tree expr)
e = GIMPLE_STMT_OPERAND (stmt, 1);
if (/* Casts are simple. */
- TREE_CODE (e) != NOP_EXPR
- && TREE_CODE (e) != CONVERT_EXPR
+ !TEST_CONVERT_NOPS_P (e)
/* Copies are simple. */
&& TREE_CODE (e) != SSA_NAME
/* Assignments of invariants are simple. */
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 132974)
+++ gcc/tree.c (working copy)
@@ -5986,8 +5986,7 @@ get_unwidened (tree op, tree for_type)
&& TYPE_UNSIGNED (type));
tree win = op;
- while (TREE_CODE (op) == NOP_EXPR
- || TREE_CODE (op) == CONVERT_EXPR)
+ while (TEST_CONVERT_NOPS_P (op))
{
int bitschange;
@@ -6025,8 +6024,7 @@ get_unwidened (tree op, tree for_type)
Let's avoid computing it if it does not affect WIN
and if UNS will not be needed again. */
if ((uns
- || TREE_CODE (op) == NOP_EXPR
- || TREE_CODE (op) == CONVERT_EXPR)
+ || TEST_CONVERT_NOPS_P (op))
&& TYPE_UNSIGNED (TREE_TYPE (op)))
{
uns = 1;
Index: gcc/tree-ssa-alias-warnings.c
===================================================================
--- gcc/tree-ssa-alias-warnings.c (revision 132974)
+++ gcc/tree-ssa-alias-warnings.c (working copy)
@@ -258,8 +258,7 @@ find_alias_site_helper (tree var ATTRIBU
tree rhs_pointer = get_rhs (stmt);
tree to_match = NULL_TREE;
- while (TREE_CODE (rhs_pointer) == NOP_EXPR
- || TREE_CODE (rhs_pointer) == CONVERT_EXPR
+ while (TEST_CONVERT_NOPS_P (rhs_pointer)
|| TREE_CODE (rhs_pointer) == VIEW_CONVERT_EXPR)
rhs_pointer = TREE_OPERAND (rhs_pointer, 0);
@@ -720,8 +719,7 @@ already_warned_in_frontend_p (tree stmt)
rhs_pointer = get_rhs (stmt);
- if ((TREE_CODE (rhs_pointer) == NOP_EXPR
- || TREE_CODE (rhs_pointer) == CONVERT_EXPR
+ if ((TEST_CONVERT_NOPS_P (rhs_pointer)
|| TREE_CODE (rhs_pointer) == VIEW_CONVERT_EXPR)
&& TREE_NO_WARNING (rhs_pointer))
return true;
Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c (revision 132974)
+++ gcc/fold-const.c (working copy)
@@ -6784,8 +6784,7 @@ fold_sign_changed_comparison (enum tree_
tree arg0_inner;
tree inner_type, outer_type;
- if (TREE_CODE (arg0) != NOP_EXPR
- && TREE_CODE (arg0) != CONVERT_EXPR)
+ if (!TEST_CONVERT_NOPS_P (arg0))
return NULL_TREE;
outer_type = TREE_TYPE (arg0);
@@ -6805,8 +6804,7 @@ fold_sign_changed_comparison (enum tree_
return NULL_TREE;
if (TREE_CODE (arg1) != INTEGER_CST
- && !((TREE_CODE (arg1) == NOP_EXPR
- || TREE_CODE (arg1) == CONVERT_EXPR)
+ && !(TEST_CONVERT_NOPS_P (arg1)
&& TREE_TYPE (TREE_OPERAND (arg1, 0)) == inner_type))
return NULL_TREE;
@@ -7715,8 +7713,7 @@ fold_unary (enum tree_code code, tree ty
TREE_OPERAND (op0, 1));
/* Handle cases of two conversions in a row. */
- if (TREE_CODE (op0) == NOP_EXPR
- || TREE_CODE (op0) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (op0))
{
tree inside_type = TREE_TYPE (TREE_OPERAND (op0, 0));
tree inter_type = TREE_TYPE (op0);
@@ -7916,8 +7913,7 @@ fold_unary (enum tree_code code, tree ty
if (INTEGRAL_TYPE_P (type)
&& TREE_CODE (op0) == BIT_NOT_EXPR
&& INTEGRAL_TYPE_P (TREE_TYPE (op0))
- && (TREE_CODE (TREE_OPERAND (op0, 0)) == NOP_EXPR
- || TREE_CODE (TREE_OPERAND (op0, 0)) == CONVERT_EXPR)
+ && TEST_CONVERT_NOPS_P (TREE_OPERAND (op0, 0))
&& TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (op0)))
{
tem = TREE_OPERAND (TREE_OPERAND (op0, 0), 0);
@@ -7976,8 +7968,7 @@ fold_unary (enum tree_code code, tree ty
return fold_convert (type, op0);
/* Strip inner integral conversions that do not change the precision. */
- if ((TREE_CODE (op0) == NOP_EXPR
- || TREE_CODE (op0) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (op0)
&& (INTEGRAL_TYPE_P (TREE_TYPE (op0))
|| POINTER_TYPE_P (TREE_TYPE (op0)))
&& (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (op0, 0)))
@@ -8747,8 +8742,7 @@ fold_comparison (enum tree_code code, tr
}
if (TREE_CODE (TREE_TYPE (arg0)) == INTEGER_TYPE
- && (TREE_CODE (arg0) == NOP_EXPR
- || TREE_CODE (arg0) == CONVERT_EXPR))
+ && TEST_CONVERT_NOPS_P (arg0))
{
/* If we are widening one operand of an integer comparison,
see if the other operand is similarly being widened. Perhaps we
@@ -12509,8 +12503,7 @@ fold_binary (enum tree_code code, tree t
if ((code == LT_EXPR || code == GE_EXPR)
&& TYPE_UNSIGNED (TREE_TYPE (arg0))
- && (TREE_CODE (arg1) == NOP_EXPR
- || TREE_CODE (arg1) == CONVERT_EXPR)
+ && TEST_CONVERT_NOPS_P (arg1)
&& TREE_CODE (TREE_OPERAND (arg1, 0)) == LSHIFT_EXPR
&& integer_onep (TREE_OPERAND (TREE_OPERAND (arg1, 0), 0)))
return
Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c (revision 132974)
+++ gcc/objc/objc-act.c (working copy)
@@ -6267,8 +6267,7 @@ objc_finish_message_expr (tree receiver,
rtype = receiver;
while (TREE_CODE (rtype) == COMPOUND_EXPR
|| TREE_CODE (rtype) == MODIFY_EXPR
- || TREE_CODE (rtype) == NOP_EXPR
- || TREE_CODE (rtype) == CONVERT_EXPR
+ || TEST_CONVERT_NOPS_P (rtype)
|| TREE_CODE (rtype) == COMPONENT_REF)
rtype = TREE_OPERAND (rtype, 0);
self = (rtype == self_decl);
Index: gcc/tree-gimple.c
===================================================================
--- gcc/tree-gimple.c (revision 132974)
+++ gcc/tree-gimple.c (working copy)
@@ -428,8 +428,7 @@ is_gimple_min_lval (tree t)
bool
is_gimple_cast (tree t)
{
- return (TREE_CODE (t) == NOP_EXPR
- || TREE_CODE (t) == CONVERT_EXPR
+ return (TEST_CONVERT_NOPS_P (t)
|| TREE_CODE (t) == FIX_TRUNC_EXPR);
}
Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c (revision 132974)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -1497,8 +1497,7 @@ simplify_unary_expression (tree rhs)
if (VN_INFO (op0)->has_constants)
op0 = valueize_expr (VN_INFO (op0)->expr);
- else if (TREE_CODE (rhs) == NOP_EXPR
- || TREE_CODE (rhs) == CONVERT_EXPR
+ else if (TEST_CONVERT_NOPS_P (rhs)
|| TREE_CODE (rhs) == REALPART_EXPR
|| TREE_CODE (rhs) == IMAGPART_EXPR
|| TREE_CODE (rhs) == VIEW_CONVERT_EXPR)
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c (revision 132974)
+++ gcc/tree-ssa-loop-ivopts.c (working copy)
@@ -772,8 +772,7 @@ determine_base_object (tree expr)
/* If this is a pointer casted to any type, we need to determine
the base object for the pointer; so handle conversions before
throwing away non-pointer expressions. */
- if (TREE_CODE (expr) == NOP_EXPR
- || TREE_CODE (expr) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (expr))
return determine_base_object (TREE_OPERAND (expr, 0));
if (!POINTER_TYPE_P (TREE_TYPE (expr)))
@@ -2674,8 +2673,7 @@ determine_common_wider_type (tree *a, tr
tree suba, subb;
tree atype = TREE_TYPE (*a);
- if ((TREE_CODE (*a) == NOP_EXPR
- || TREE_CODE (*a) == CONVERT_EXPR))
+ if (TEST_CONVERT_NOPS_P (*a))
{
suba = TREE_OPERAND (*a, 0);
wider_type = TREE_TYPE (suba);
@@ -2685,8 +2683,7 @@ determine_common_wider_type (tree *a, tr
else
return atype;
- if ((TREE_CODE (*b) == NOP_EXPR
- || TREE_CODE (*b) == CONVERT_EXPR))
+ if (TEST_CONVERT_NOPS_P (*b))
{
subb = TREE_OPERAND (*b, 0);
if (TYPE_PRECISION (wider_type) != TYPE_PRECISION (TREE_TYPE (subb)))
Index: gcc/tree-stdarg.c
===================================================================
--- gcc/tree-stdarg.c (revision 132974)
+++ gcc/tree-stdarg.c (working copy)
@@ -158,8 +158,7 @@ va_list_counter_bump (struct stdarg_info
continue;
}
- if ((TREE_CODE (rhs) == NOP_EXPR
- || TREE_CODE (rhs) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (rhs)
&& TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME)
{
lhs = TREE_OPERAND (rhs, 0);
@@ -217,8 +216,7 @@ va_list_counter_bump (struct stdarg_info
continue;
}
- if ((TREE_CODE (rhs) == NOP_EXPR
- || TREE_CODE (rhs) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (rhs)
&& TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME)
{
lhs = TREE_OPERAND (rhs, 0);
@@ -447,8 +445,7 @@ check_va_list_escapes (struct stdarg_inf
if (((TREE_CODE (rhs) == POINTER_PLUS_EXPR
|| TREE_CODE (rhs) == PLUS_EXPR)
&& TREE_CODE (TREE_OPERAND (rhs, 1)) == INTEGER_CST)
- || TREE_CODE (rhs) == NOP_EXPR
- || TREE_CODE (rhs) == CONVERT_EXPR)
+ || TEST_CONVERT_NOPS_P (rhs))
rhs = TREE_OPERAND (rhs, 0);
if (TREE_CODE (rhs) != SSA_NAME
@@ -555,8 +552,7 @@ check_all_va_list_escapes (struct stdarg
statements. */
if ((TREE_CODE (rhs) == POINTER_PLUS_EXPR
&& TREE_CODE (TREE_OPERAND (rhs, 1)) == INTEGER_CST)
- || TREE_CODE (rhs) == NOP_EXPR
- || TREE_CODE (rhs) == CONVERT_EXPR)
+ || TEST_CONVERT_NOPS_P (rhs))
rhs = TREE_OPERAND (rhs, 0);
if (rhs == use)
Index: gcc/tree-ssa-alias.c
===================================================================
--- gcc/tree-ssa-alias.c (revision 132974)
+++ gcc/tree-ssa-alias.c (working copy)
@@ -3023,8 +3023,7 @@ is_escape_site (tree stmt)
if (lhs == NULL_TREE)
return ESCAPE_UNKNOWN;
- if (TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 1)) == NOP_EXPR
- || TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 1)) == CONVERT_EXPR
+ if (TEST_CONVERT_NOPS_P (GIMPLE_STMT_OPERAND (stmt, 1))
|| TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 1)) == VIEW_CONVERT_EXPR)
{
tree from
Index: gcc/tree-ssa-ifcombine.c
===================================================================
--- gcc/tree-ssa-ifcombine.c (revision 132974)
+++ gcc/tree-ssa-ifcombine.c (working copy)
@@ -176,8 +176,7 @@ recognize_single_bit_test (tree cond_exp
if (TREE_CODE (t) != GIMPLE_MODIFY_STMT)
break;
t = GIMPLE_STMT_OPERAND (t, 1);
- if (TREE_CODE (t) == NOP_EXPR
- || TREE_CODE (t) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (t))
t = TREE_OPERAND (t, 0);
} while (TREE_CODE (t) == SSA_NAME);
Index: gcc/matrix-reorg.c
===================================================================
--- gcc/matrix-reorg.c (revision 132974)
+++ gcc/matrix-reorg.c (working copy)
@@ -410,7 +410,7 @@ mtt_info_eq (const void *mtt1, const voi
static tree
get_inner_of_cast_expr (tree t)
{
- while (TREE_CODE (t) == CONVERT_EXPR || TREE_CODE (t) == NOP_EXPR
+ while (TEST_CONVERT_NOPS_P (t)
|| TREE_CODE (t) == VIEW_CONVERT_EXPR)
t = TREE_OPERAND (t, 0);
@@ -428,7 +428,7 @@ may_flatten_matrices_1 (tree stmt)
{
case GIMPLE_MODIFY_STMT:
t = GIMPLE_STMT_OPERAND (stmt, 1);
- while (TREE_CODE (t) == CONVERT_EXPR || TREE_CODE (t) == NOP_EXPR)
+ while (TEST_CONVERT_NOPS_P (t))
{
if (TREE_TYPE (t) && POINTER_TYPE_P (TREE_TYPE (t)))
{
Index: gcc/tree-vect-analyze.c
===================================================================
--- gcc/tree-vect-analyze.c (revision 132974)
+++ gcc/tree-vect-analyze.c (working copy)
@@ -218,8 +218,7 @@ vect_determine_vectorization_factor (loo
scalar_type = TREE_TYPE (GIMPLE_STMT_OPERAND (stmt, 0));
operation = GIMPLE_STMT_OPERAND (stmt, 1);
- if (TREE_CODE (operation) == NOP_EXPR
- || TREE_CODE (operation) == CONVERT_EXPR
+ if (TEST_CONVERT_NOPS_P (operation)
|| TREE_CODE (operation) == WIDEN_MULT_EXPR
|| TREE_CODE (operation) == FLOAT_EXPR)
{
Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c (revision 132974)
+++ gcc/c-typeck.c (working copy)
@@ -1978,8 +1978,7 @@ build_indirect_ref (tree ptr, const char
if (TREE_CODE (type) == POINTER_TYPE)
{
- if (TREE_CODE (pointer) == CONVERT_EXPR
- || TREE_CODE (pointer) == NOP_EXPR
+ if (TEST_CONVERT_NOPS_P (pointer)
|| TREE_CODE (pointer) == VIEW_CONVERT_EXPR)
{
/* If a warning is issued, mark it to avoid duplicates from
@@ -2399,8 +2398,7 @@ build_function_call (tree function, tree
expression if necessary. This has the nice side-effect to prevent
the tree-inliner from generating invalid assignment trees which may
blow up in the RTL expander later. */
- if ((TREE_CODE (function) == NOP_EXPR
- || TREE_CODE (function) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (function)
&& TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
&& TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
&& !comptypes (fntype, TREE_TYPE (tem)))
@@ -2816,13 +2814,13 @@ pointer_diff (tree op0, tree op1)
different mode in place.)
So first try to find a common term here 'by hand'; we want to cover
at least the cases that occur in legal static initializers. */
- if ((TREE_CODE (op0) == NOP_EXPR || TREE_CODE (op0) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (op0)
&& (TYPE_PRECISION (TREE_TYPE (op0))
== TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))))
con0 = TREE_OPERAND (op0, 0);
else
con0 = op0;
- if ((TREE_CODE (op1) == NOP_EXPR || TREE_CODE (op1) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (op1)
&& (TYPE_PRECISION (TREE_TYPE (op1))
== TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op1, 0)))))
con1 = TREE_OPERAND (op1, 0);
@@ -3550,13 +3548,11 @@ build_compound_expr (tree expr1, tree ex
if (warn_unused_value)
{
if (VOID_TYPE_P (TREE_TYPE (expr1))
- && (TREE_CODE (expr1) == NOP_EXPR
- || TREE_CODE (expr1) == CONVERT_EXPR))
+ && TEST_CONVERT_NOPS_P (expr1))
; /* (void) a, b */
else if (VOID_TYPE_P (TREE_TYPE (expr1))
&& TREE_CODE (expr1) == COMPOUND_EXPR
- && (TREE_CODE (TREE_OPERAND (expr1, 1)) == CONVERT_EXPR
- || TREE_CODE (TREE_OPERAND (expr1, 1)) == NOP_EXPR))
+ && TEST_CONVERT_NOPS_P (TREE_OPERAND (expr1, 1)))
; /* (void) a, (void) b, c */
else
warning (OPT_Wunused_value,
Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c (revision 132974)
+++ gcc/gimplify.c (working copy)
@@ -1640,8 +1640,7 @@ static enum gimplify_status
gimplify_conversion (tree *expr_p)
{
tree tem;
- gcc_assert (TREE_CODE (*expr_p) == NOP_EXPR
- || TREE_CODE (*expr_p) == CONVERT_EXPR);
+ gcc_assert (TEST_CONVERT_NOPS_P (*expr_p));
/* Then strip away all but the outermost conversion. */
STRIP_SIGN_NOPS (TREE_OPERAND (*expr_p, 0));
@@ -1667,7 +1666,7 @@ gimplify_conversion (tree *expr_p)
/* If we still have a conversion at the toplevel,
then canonicalize some constructs. */
- if (TREE_CODE (*expr_p) == NOP_EXPR || TREE_CODE (*expr_p) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (*expr_p))
{
tree sub = TREE_OPERAND (*expr_p, 0);
Index: gcc/tree-ssa-phiopt.c
===================================================================
--- gcc/tree-ssa-phiopt.c (revision 132974)
+++ gcc/tree-ssa-phiopt.c (working copy)
@@ -587,8 +587,7 @@ conditional_replacement (basic_block con
/* Only "real" casts are OK here, not everything that is
acceptable to is_gimple_cast. Make sure we don't do
anything stupid here. */
- gcc_assert (TREE_CODE (cond) == NOP_EXPR
- || TREE_CODE (cond) == CONVERT_EXPR);
+ gcc_assert (TEST_CONVERT_NOPS_P (cond));
op0 = TREE_OPERAND (cond, 0);
tmp = create_tmp_var (TREE_TYPE (op0), NULL);
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c (revision 132974)
+++ gcc/cfgexpand.c (working copy)
@@ -1800,8 +1800,7 @@ discover_nonconstant_array_refs_r (tree
|| TREE_CODE (t) == REALPART_EXPR
|| TREE_CODE (t) == IMAGPART_EXPR
|| TREE_CODE (t) == VIEW_CONVERT_EXPR
- || TREE_CODE (t) == NOP_EXPR
- || TREE_CODE (t) == CONVERT_EXPR)
+ || TEST_CONVERT_NOPS_P (t))
t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) == ARRAY_REF || TREE_CODE (t) == ARRAY_RANGE_REF)
Index: gcc/tree-ssa-forwprop.c
===================================================================
--- gcc/tree-ssa-forwprop.c (revision 132974)
+++ gcc/tree-ssa-forwprop.c (working copy)
@@ -273,8 +273,7 @@ can_propagate_from (tree def_stmt)
then we can not apply optimizations as some targets require function
pointers to be canonicalized and in this case this optimization could
eliminate a necessary canonicalization. */
- if ((TREE_CODE (rhs) == NOP_EXPR
- || TREE_CODE (rhs) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (rhs)
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (rhs, 0)))
&& TREE_CODE (TREE_TYPE (TREE_TYPE
(TREE_OPERAND (rhs, 0)))) == FUNCTION_TYPE)
@@ -560,8 +559,7 @@ forward_propagate_addr_expr_1 (tree name
a conversion to def_rhs type separate, though. */
if (TREE_CODE (lhs) == SSA_NAME
&& (rhs == name
- || TREE_CODE (rhs) == NOP_EXPR
- || TREE_CODE (rhs) == CONVERT_EXPR)
+ || TEST_CONVERT_NOPS_P (rhs))
&& useless_type_conversion_p (TREE_TYPE (rhs), TREE_TYPE (def_rhs)))
{
/* Only recurse if we don't deal with a single use. */
@@ -741,8 +739,7 @@ forward_propagate_addr_expr (tree name,
if (result
&& TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 0)) == SSA_NAME
&& (TREE_CODE (use_rhs) == SSA_NAME
- || ((TREE_CODE (use_rhs) == NOP_EXPR
- || TREE_CODE (use_rhs) == CONVERT_EXPR)
+ || (TEST_CONVERT_NOPS_P (use_rhs)
&& TREE_CODE (TREE_OPERAND (use_rhs, 0)) == SSA_NAME)))
{
block_stmt_iterator bsi = bsi_for_stmt (use_stmt);
@@ -781,8 +778,7 @@ forward_propagate_comparison (tree cond,
/* Conversion of the condition result to another integral type. */
if (TREE_CODE (use_stmt) == GIMPLE_MODIFY_STMT
- && (TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == CONVERT_EXPR
- || TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == NOP_EXPR
+ && (TEST_CONVERT_NOPS_P (GIMPLE_STMT_OPERAND (use_stmt, 1))
|| COMPARISON_CLASS_P (GIMPLE_STMT_OPERAND (use_stmt, 1))
|| TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == TRUTH_NOT_EXPR)
&& INTEGRAL_TYPE_P (TREE_TYPE (GIMPLE_STMT_OPERAND (use_stmt, 0))))
@@ -791,8 +787,7 @@ forward_propagate_comparison (tree cond,
tree rhs = GIMPLE_STMT_OPERAND (use_stmt, 1);
/* We can propagate the condition into a conversion. */
- if (TREE_CODE (rhs) == CONVERT_EXPR
- || TREE_CODE (rhs) == NOP_EXPR)
+ if (TEST_CONVERT_NOPS_P (rhs))
{
/* Avoid using fold here as that may create a COND_EXPR with
non-boolean condition as canonical form. */
@@ -982,8 +977,7 @@ tree_ssa_forward_propagate_single_use_va
if (TREE_CODE (rhs) == ADDR_EXPR
/* Handle pointer conversions on invariant addresses
as well, as this is valid gimple. */
- || ((TREE_CODE (rhs) == NOP_EXPR
- || TREE_CODE (rhs) == CONVERT_EXPR)
+ || (TEST_CONVERT_NOPS_P (rhs)
&& TREE_CODE (TREE_OPERAND (rhs, 0)) == ADDR_EXPR
&& POINTER_TYPE_P (TREE_TYPE (rhs))))
{
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c (revision 132974)
+++ gcc/c-common.c (working copy)
@@ -3416,7 +3416,7 @@ c_alignof_expr (tree expr)
tree best = t;
int bestalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
- while ((TREE_CODE (t) == NOP_EXPR || TREE_CODE (t) == CONVERT_EXPR)
+ while (TEST_CONVERT_NOPS_P (t)
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == POINTER_TYPE)
{
int thisalign;
@@ -6484,7 +6484,7 @@ check_function_arguments_recurse (void (
void *ctx, tree param,
unsigned HOST_WIDE_INT param_num)
{
- if ((TREE_CODE (param) == NOP_EXPR || TREE_CODE (param) == CONVERT_EXPR)
+ if (TEST_CONVERT_NOPS_P (param)
&& (TYPE_PRECISION (TREE_TYPE (param))
== TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (param, 0)))))
{
Index: gcc/config/alpha/alpha.c
===================================================================
--- gcc/config/alpha/alpha.c (revision 132974)
+++ gcc/config/alpha/alpha.c (working copy)
@@ -5847,8 +5847,7 @@ va_list_skip_additions (tree lhs)
if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
rhs = TREE_OPERAND (rhs, 0);
- if ((TREE_CODE (rhs) != NOP_EXPR
- && TREE_CODE (rhs) != CONVERT_EXPR
+ if ((!TEST_CONVERT_NOPS_P (rhs)
&& ((TREE_CODE (rhs) != PLUS_EXPR
&& TREE_CODE (rhs) != POINTER_PLUS_EXPR)
|| TREE_CODE (TREE_OPERAND (rhs, 1)) != INTEGER_CST
Index: gcc/convert.c
===================================================================
--- gcc/convert.c (revision 132974)
+++ gcc/convert.c (working copy)
@@ -98,8 +98,7 @@ strip_float_extensions (tree exp)
return build_real (type, real_value_truncate (TYPE_MODE (type), orig));
}
- if (TREE_CODE (exp) != NOP_EXPR
- && TREE_CODE (exp) != CONVERT_EXPR)
+ if (!TEST_CONVERT_NOPS_P (exp))
return exp;
sub = TREE_OPERAND (exp, 0);