This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: rfc NOP vs CONVERT (was: Simplifying Gimple Generation)
- From: Michael Matz <matz at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Steven Bosscher <stevenb dot gcc at gmail dot com>
- Date: Mon, 19 Nov 2012 16:35:45 +0100 (CET)
- Subject: Re: rfc NOP vs CONVERT (was: Simplifying Gimple Generation)
- References: <CAGqM8fZbnET=4GGrBt-sXJ-jweTxYYLAGdaYuzK2HfiwCi7K=A@mail.gmail.com> <alpine.LNX.2.00.1211151523550.21868@wotan.suse.de> <CAD_=9DSQ2AdOaEgpJpm7RAAR9EJSWemHRmq6khno6hF9mejE=g@mail.gmail.com> <alpine.LNX.2.00.1211161529030.21868@wotan.suse.de> <CA+=Sn1khtkyja9Nbr31WQ6f5-vC4FNRiAp4AvDRaJqT=agTeUg@mail.gmail.com> <alpine.LNX.2.00.1211191405170.21868@wotan.suse.de> <CABu31nNP55nAEFSFgTO6oEsDakYxSVBjran8PQvJTCMBEV_m3A@mail.gmail.com>
Hi,
On Mon, 19 Nov 2012, Steven Bosscher wrote:
> On Mon, Nov 19, 2012 at 2:10 PM, Michael Matz wrote:
> > Hi,
> >
> > On Fri, 16 Nov 2012, Andrew Pinski wrote:
> >
> >> >> Ah, yes. This one was amusing. When we were drafting the proposal,
> >> >> Lawrence kept wondering what this NOP_EXPR thing is. I've been
> >> >> suffering this name for so long, that it no longer irritates me.
> >> >> Had it been named CAST_EXPR, or even NOP_CAST_EXPR, he would have
> >> >> probably kept it in the example code :)
> >> >
> >> > We have CONVERT_EXPR, but it currently doesn't do _quite_ the same as
> >> > NOP_EXPR. I once wanted to merge them (with CONVERT_EXPR surviving),
> >> > but it stalled somewhere, couple years ago.
> >>
> >> I think the only difference now is in the front-ends IIRC.
> >
> > No, because my patch didn't go in. There are still various cases in the
> > middle end that explicitely check for equality with NOP_EXPR, instead of
> > using CONVERT_EXPR_P or CONVERT_EXPR_CODE_P or CASE_CONVERT to work with
> > both.
> >
> > See the patch below from three years ago. Of course it doesn't apply
> > anymore, but I can update it if there's some consensus that we want to go
> > that route.
>
> At this point, you probably wanted to attach a patch :-)
I thought everybody can look into my head. Well, if you can't
due to my aluminium hat, here it is electronically :)
Ciao,
Michael.
Index: gcc/builtins.c
===================================================================
--- gcc.orig/builtins.c 2009-09-28 13:06:24.000000000 +0200
+++ gcc/builtins.c 2009-09-29 15:01:44.000000000 +0200
@@ -6873,7 +6873,7 @@ fold_builtin_expect (location_t loc, tre
/* Distribute the expected value over short-circuiting operators.
See through the cast from truthvalue_type_node to long. */
inner = arg0;
- while (TREE_CODE (inner) == NOP_EXPR
+ while (CONVERT_EXPR_P (inner)
&& INTEGRAL_TYPE_P (TREE_TYPE (inner))
&& INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (inner, 0))))
inner = TREE_OPERAND (inner, 0);
@@ -7028,7 +7028,7 @@ integer_valued_real_p (tree t)
case REAL_CST:
return real_isinteger (TREE_REAL_CST_PTR (t), TYPE_MODE (TREE_TYPE (t)));
- case NOP_EXPR:
+ CASE_CONVERT:
{
tree type = TREE_TYPE (TREE_OPERAND (t, 0));
if (TREE_CODE (type) == INTEGER_TYPE)
@@ -13843,7 +13843,7 @@ fold_call_stmt (gimple stmt, bool ignore
if (gimple_has_location (stmt))
{
tree realret = ret;
- if (TREE_CODE (ret) == NOP_EXPR)
+ if (CONVERT_EXPR_P (ret))
realret = TREE_OPERAND (ret, 0);
if (CAN_HAVE_LOCATION_P (realret)
&& !EXPR_HAS_LOCATION (realret))
Index: gcc/c-common.c
===================================================================
--- gcc.orig/c-common.c 2009-09-24 14:54:14.000000000 +0200
+++ gcc/c-common.c 2009-09-29 15:02:49.000000000 +0200
@@ -8348,7 +8348,7 @@ fold_offsetof_1 (tree expr, tree stop_re
gcc_assert (integer_zerop (expr));
return size_zero_node;
- case NOP_EXPR:
+ CASE_CONVERT:
case INDIRECT_REF:
base = fold_offsetof_1 (TREE_OPERAND (expr, 0), stop_ref);
gcc_assert (base == error_mark_node || base == size_zero_node);
Index: gcc/c-omp.c
===================================================================
--- gcc.orig/c-omp.c 2009-07-20 07:12:40.000000000 +0200
+++ gcc/c-omp.c 2009-09-29 15:04:13.000000000 +0200
@@ -318,7 +318,7 @@ c_finish_omp_for (location_t locus, tree
We want to force:
i < (int)n; */
- if (TREE_CODE (op0) == NOP_EXPR
+ if (CONVERT_EXPR_P (op0)
&& decl == TREE_OPERAND (op0, 0))
{
TREE_OPERAND (cond, 0) = TREE_OPERAND (op0, 0);
@@ -326,7 +326,7 @@ c_finish_omp_for (location_t locus, tree
= fold_build1_loc (elocus, NOP_EXPR, TREE_TYPE (decl),
TREE_OPERAND (cond, 1));
}
- else if (TREE_CODE (op1) == NOP_EXPR
+ else if (CONVERT_EXPR_P (op1)
&& decl == TREE_OPERAND (op1, 0))
{
TREE_OPERAND (cond, 1) = TREE_OPERAND (op1, 0);
Index: gcc/c-pretty-print.c
===================================================================
--- gcc.orig/c-pretty-print.c 2009-09-15 15:02:55.000000000 +0200
+++ gcc/c-pretty-print.c 2009-09-29 15:07:48.000000000 +0200
@@ -992,8 +992,8 @@ pp_c_complex_expr (c_pretty_printer *pp,
tree imagexpr = TREE_OPERAND (e, 1);
/* Cast of an COMPLEX_TYPE expression to a different COMPLEX_TYPE. */
- if (TREE_CODE (realexpr) == NOP_EXPR
- && TREE_CODE (imagexpr) == NOP_EXPR
+ if (CONVERT_EXPR_P (realexpr)
+ && CONVERT_EXPR_P (imagexpr)
&& TREE_TYPE (realexpr) == TREE_TYPE (type)
&& TREE_TYPE (imagexpr) == TREE_TYPE (type)
&& TREE_CODE (TREE_OPERAND (realexpr, 0)) == REALPART_EXPR
@@ -1011,7 +1011,7 @@ pp_c_complex_expr (c_pretty_printer *pp,
&& TREE_TYPE (realexpr) == TREE_TYPE (type))
{
pp_c_type_cast (pp, type);
- if (TREE_CODE (realexpr) == NOP_EXPR)
+ if (CONVERT_EXPR_P (realexpr))
realexpr = TREE_OPERAND (realexpr, 0);
pp_expression (pp, realexpr);
return;
Index: gcc/c-typeck.c
===================================================================
--- gcc.orig/c-typeck.c 2009-09-28 13:30:24.000000000 +0200
+++ gcc/c-typeck.c 2009-09-29 15:56:14.000000000 +0200
@@ -2630,7 +2630,7 @@ build_function_call_vec (location_t loc,
else
result = fold_build_call_array_loc (loc, TREE_TYPE (fntype),
function, nargs, argarray);
- if (TREE_CODE (result) == NOP_EXPR
+ if (CONVERT_EXPR_P (result)
&& TREE_CODE (TREE_OPERAND (result, 0)) == INTEGER_CST)
STRIP_TYPE_NOPS (result);
}
@@ -3193,7 +3193,7 @@ build_unary_op (location_t location,
switch (code)
{
- case CONVERT_EXPR:
+ CASE_CONVERT:
/* This is used for unary plus, because a CONVERT_EXPR
is enough to prevent anybody from looking inside for
associativity, but won't generate any code. */
@@ -4537,6 +4537,7 @@ build_modify_expr (location_t location,
/* If a binary op has been requested, combine the old LHS value with the RHS
producing the value we should actually store into the LHS. */
+ gcc_assert (modifycode != CONVERT_EXPR);
if (modifycode != NOP_EXPR)
{
lhs = c_fully_fold (lhs, false, NULL);
@@ -8693,7 +8694,7 @@ c_finish_stmt_expr (location_t loc, tree
/* Unwrap a no-op NOP_EXPR as added by c_finish_expr_stmt. This avoids
tree_expr_nonnegative_p giving up immediately. */
val = last;
- if (TREE_CODE (val) == NOP_EXPR
+ if (CONVERT_EXPR_P (val)
&& TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0)))
val = TREE_OPERAND (val, 0);
Index: gcc/cfgexpand.c
===================================================================
--- gcc.orig/cfgexpand.c 2009-09-24 14:54:14.000000000 +0200
+++ gcc/cfgexpand.c 2009-09-29 15:03:33.000000000 +0200
@@ -2383,8 +2383,7 @@ expand_debug_expr (tree exp)
adjust_mode:
case PAREN_EXPR:
- case NOP_EXPR:
- case CONVERT_EXPR:
+ CASE_CONVERT:
{
enum machine_mode inner_mode = GET_MODE (op0);
Index: gcc/convert.c
===================================================================
--- gcc.orig/convert.c 2009-08-25 08:12:36.000000000 +0200
+++ gcc/convert.c 2009-09-29 15:05:16.000000000 +0200
@@ -772,7 +772,7 @@ convert_to_integer (tree type, tree expr
TREE_OPERAND (expr, 0))));
}
- case NOP_EXPR:
+ CASE_CONVERT:
/* Don't introduce a
"can't convert between vector values of different size" error. */
if (TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == VECTOR_TYPE
Index: gcc/dojump.c
===================================================================
--- gcc.orig/dojump.c 2009-08-27 18:33:37.000000000 +0200
+++ gcc/dojump.c 2009-09-29 15:13:38.000000000 +0200
@@ -363,13 +363,12 @@ do_jump (tree exp, rtx if_false_label, r
break;
#endif
- case NOP_EXPR:
+ CASE_CONVERT:
if (TREE_CODE (TREE_OPERAND (exp, 0)) == COMPONENT_REF
|| TREE_CODE (TREE_OPERAND (exp, 0)) == BIT_FIELD_REF
|| TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_REF
|| TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_RANGE_REF)
goto normal;
- case CONVERT_EXPR:
/* If we are narrowing the operand, we have to do the compare in the
narrower mode. */
if ((TYPE_PRECISION (TREE_TYPE (exp))
Index: gcc/except.c
===================================================================
--- gcc.orig/except.c 2009-09-15 15:02:55.000000000 +0200
+++ gcc/except.c 2009-09-29 15:15:06.000000000 +0200
@@ -674,6 +674,7 @@ add_type_for_runtime (tree type)
tree *slot;
/* If TYPE is NOP_EXPR, it means that it already is a runtime type. */
+ gcc_assert (TREE_CODE (type) != CONVERT_EXPR);
if (TREE_CODE (type) == NOP_EXPR)
return;
@@ -692,6 +693,7 @@ lookup_type_for_runtime (tree type)
tree *slot;
/* If TYPE is NOP_EXPR, it means that it already is a runtime type. */
+ gcc_assert (TREE_CODE (type) != CONVERT_EXPR);
if (TREE_CODE (type) == NOP_EXPR)
return type;
Index: gcc/fold-const.c
===================================================================
--- gcc.orig/fold-const.c 2009-09-28 13:30:24.000000000 +0200
+++ gcc/fold-const.c 2009-09-29 15:55:34.000000000 +0200
@@ -1197,7 +1197,7 @@ negate_expr_p (tree t)
return negate_expr_p (TREE_OPERAND (t, 1))
|| negate_expr_p (TREE_OPERAND (t, 0));
- case NOP_EXPR:
+ CASE_CONVERT:
/* Negate -((double)float) as (double)(-float). */
if (TREE_CODE (type) == REAL_TYPE)
{
@@ -1388,7 +1388,7 @@ fold_negate_expr (location_t loc, tree t
}
break;
- case NOP_EXPR:
+ CASE_CONVERT:
/* Convert -((double)float) into (double)(-float). */
if (TREE_CODE (type) == REAL_TYPE)
{
@@ -4471,7 +4471,7 @@ sign_bit_p (tree exp, const_tree val)
return exp;
/* Handle extension from a narrower type. */
- if (TREE_CODE (exp) == NOP_EXPR
+ if (CONVERT_EXPR_P (exp)
&& TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))) < width)
return sign_bit_p (TREE_OPERAND (exp, 0), val);
@@ -8626,8 +8626,8 @@ fold_unary_loc (location_t loc, enum tre
if (POINTER_TYPE_P (type)
&& TREE_CODE (arg0) == POINTER_PLUS_EXPR
&& (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
- || TREE_CODE (TREE_OPERAND (arg0, 0)) == NOP_EXPR
- || TREE_CODE (TREE_OPERAND (arg0, 1)) == NOP_EXPR))
+ || CONVERT_EXPR_P (TREE_OPERAND (arg0, 0))
+ || CONVERT_EXPR_P (TREE_OPERAND (arg0, 1))))
{
tree arg00 = TREE_OPERAND (arg0, 0);
tree arg01 = TREE_OPERAND (arg0, 1);
@@ -8727,7 +8727,7 @@ fold_unary_loc (location_t loc, enum tre
else if (TREE_CODE (arg0) == NEGATE_EXPR)
return fold_build1_loc (loc, ABS_EXPR, type, TREE_OPERAND (arg0, 0));
/* Convert fabs((double)float) into (double)fabsf(float). */
- else if (TREE_CODE (arg0) == NOP_EXPR
+ else if (CONVERT_EXPR_P (arg0)
&& TREE_CODE (type) == REAL_TYPE)
{
tree targ0 = strip_float_extensions (arg0);
@@ -11649,7 +11649,7 @@ fold_binary_loc (location_t loc,
if (t1 != NULL_TREE)
return t1;
/* Simplify ((int)c & 0377) into (int)c, if c is unsigned char. */
- if (TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (arg0) == NOP_EXPR
+ if (TREE_CODE (arg1) == INTEGER_CST && CONVERT_EXPR_P (arg0)
&& TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (arg0, 0))))
{
unsigned int prec
@@ -11725,7 +11725,7 @@ fold_binary_loc (location_t loc,
tree arg00 = TREE_OPERAND (arg0, 0);
/* See if more bits can be proven as zero because of
zero extension. */
- if (TREE_CODE (arg00) == NOP_EXPR
+ if (CONVERT_EXPR_P (arg00)
&& TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (arg00, 0))))
{
tree inner_type = TREE_TYPE (TREE_OPERAND (arg00, 0));
@@ -14771,7 +14771,7 @@ multiple_of_p (tree type, const_tree top
}
return 0;
- case NOP_EXPR:
+ CASE_CONVERT:
/* Can't handle conversions from non-integral or wider integral type. */
if ((TREE_CODE (TREE_TYPE (TREE_OPERAND (top, 0))) != INTEGER_TYPE)
|| (TYPE_PRECISION (type)
@@ -14843,7 +14843,7 @@ tree_unary_nonnegative_warnv_p (enum tre
return tree_expr_nonnegative_warnv_p (op0,
strict_overflow_p);
- case NOP_EXPR:
+ CASE_CONVERT:
{
tree inner_type = TREE_TYPE (op0);
tree outer_type = type;
@@ -14906,8 +14906,8 @@ tree_binary_nonnegative_warnv_p (enum tr
/* zero_extend(x) + zero_extend(y) is non-negative if x and y are
both unsigned and at least 2 bits shorter than the result. */
if (TREE_CODE (type) == INTEGER_TYPE
- && TREE_CODE (op0) == NOP_EXPR
- && TREE_CODE (op1) == NOP_EXPR)
+ && CONVERT_EXPR_P (op0)
+ && CONVERT_EXPR_P (op1))
{
tree inner1 = TREE_TYPE (TREE_OPERAND (op0, 0));
tree inner2 = TREE_TYPE (TREE_OPERAND (op1, 0));
@@ -14936,13 +14936,13 @@ tree_binary_nonnegative_warnv_p (enum tr
/* zero_extend(x) * zero_extend(y) is non-negative if x and y are
both unsigned and their total bits is shorter than the result. */
if (TREE_CODE (type) == INTEGER_TYPE
- && (TREE_CODE (op0) == NOP_EXPR || TREE_CODE (op0) == INTEGER_CST)
- && (TREE_CODE (op1) == NOP_EXPR || TREE_CODE (op1) == INTEGER_CST))
+ && (CONVERT_EXPR_P (op0) || TREE_CODE (op0) == INTEGER_CST)
+ && (CONVERT_EXPR_P (op1) || TREE_CODE (op1) == INTEGER_CST))
{
- tree inner0 = (TREE_CODE (op0) == NOP_EXPR)
+ tree inner0 = CONVERT_EXPR_P (op0)
? TREE_TYPE (TREE_OPERAND (op0, 0))
: TREE_TYPE (op0);
- tree inner1 = (TREE_CODE (op1) == NOP_EXPR)
+ tree inner1 = CONVERT_EXPR_P (op1)
? TREE_TYPE (TREE_OPERAND (op1, 0))
: TREE_TYPE (op1);
@@ -15353,7 +15353,7 @@ tree_unary_nonzero_warnv_p (enum tree_co
return tree_expr_nonzero_warnv_p (op0,
strict_overflow_p);
- case NOP_EXPR:
+ CASE_CONVERT:
{
tree inner_type = TREE_TYPE (op0);
tree outer_type = type;
Index: gcc/gimple.c
===================================================================
--- gcc.orig/gimple.c 2009-09-15 15:02:55.000000000 +0200
+++ gcc/gimple.c 2009-09-29 15:27:24.000000000 +0200
@@ -2927,7 +2927,7 @@ tree
canonicalize_cond_expr_cond (tree t)
{
/* For (bool)x use x != 0. */
- if (TREE_CODE (t) == NOP_EXPR
+ if (CONVERT_EXPR_P (t)
&& TREE_TYPE (t) == boolean_type_node)
{
tree top0 = TREE_OPERAND (t, 0);
Index: gcc/gimplify.c
===================================================================
--- gcc.orig/gimplify.c 2009-09-15 15:02:55.000000000 +0200
+++ gcc/gimplify.c 2009-09-29 15:28:01.000000000 +0200
@@ -6966,7 +6966,7 @@ gimplify_expr (tree *expr_p, gimple_seq
break;
}
/* Convert (void *)&a + 4 into (void *)&a[1]. */
- if (TREE_CODE (TREE_OPERAND (*expr_p, 0)) == NOP_EXPR
+ if (CONVERT_EXPR_P (TREE_OPERAND (*expr_p, 0))
&& TREE_CODE (TREE_OPERAND (*expr_p, 1)) == INTEGER_CST
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p,
0),0)))
Index: gcc/ipa-cp.c
===================================================================
--- gcc.orig/ipa-cp.c 2009-08-17 10:53:09.000000000 +0200
+++ gcc/ipa-cp.c 2009-09-29 15:29:05.000000000 +0200
@@ -298,7 +298,7 @@ ipcp_lattice_from_jfunc (struct ipa_node
return;
cst = caller_lat->constant;
- if (jfunc->value.pass_through.operation != NOP_EXPR)
+ if (! CONVERT_EXPR_CODE_P (jfunc->value.pass_through.operation))
cst = fold_binary (jfunc->value.pass_through.operation,
TREE_TYPE (cst), cst,
jfunc->value.pass_through.operand);
Index: gcc/ipa-inline.c
===================================================================
--- gcc.orig/ipa-inline.c 2009-09-20 22:05:01.000000000 +0200
+++ gcc/ipa-inline.c 2009-09-29 15:29:34.000000000 +0200
@@ -1674,8 +1674,7 @@ likely_eliminated_by_inlining_p (gimple
/* Casts of parameters, loads from parameters passed by reference
and stores to return value or parameters are probably free after
inlining. */
- if (gimple_assign_rhs_code (stmt) == CONVERT_EXPR
- || gimple_assign_rhs_code (stmt) == NOP_EXPR
+ if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt))
|| gimple_assign_rhs_code (stmt) == VIEW_CONVERT_EXPR
|| gimple_assign_rhs_class (stmt) == GIMPLE_SINGLE_RHS)
{
Index: gcc/ipa-prop.c
===================================================================
--- gcc.orig/ipa-prop.c 2009-08-17 10:53:09.000000000 +0200
+++ gcc/ipa-prop.c 2009-09-29 15:30:58.000000000 +0200
@@ -304,7 +304,7 @@ ipa_print_node_jump_functions (FILE *f,
jump_func->value.pass_through.formal_id,
tree_code_name[(int)
jump_func->value.pass_through.operation]);
- if (jump_func->value.pass_through.operation != NOP_EXPR)
+ if (! CONVERT_EXPR_CODE_P (jump_func->value.pass_through.operation))
print_generic_expr (dump_file,
jump_func->value.pass_through.operand, 0);
fprintf (dump_file, "\n");
@@ -997,7 +997,7 @@ update_jump_functions_after_inlining (st
/* We must check range due to calls with variable number of arguments and
we cannot combine jump functions with operations. */
- if (dst->value.pass_through.operation != NOP_EXPR
+ if (! CONVERT_EXPR_CODE_P (dst->value.pass_through.operation)
|| (dst->value.pass_through.formal_id
>= ipa_get_cs_argument_count (top)))
{
@@ -1064,7 +1064,7 @@ update_call_notes_after_inlining (struct
jfunc = ipa_get_ith_jump_func (top, nt->formal_id);
if (jfunc->type == IPA_JF_PASS_THROUGH
- && jfunc->value.pass_through.operation == NOP_EXPR)
+ && CONVERT_EXPR_CODE_P (jfunc->value.pass_through.operation))
nt->formal_id = jfunc->value.pass_through.formal_id;
else if (jfunc->type == IPA_JF_CONST
|| jfunc->type == IPA_JF_CONST_MEMBER_PTR)
Index: gcc/tree-affine.c
===================================================================
--- gcc.orig/tree-affine.c 2009-04-05 08:06:20.000000000 +0200
+++ gcc/tree-affine.c 2009-09-29 15:32:14.000000000 +0200
@@ -588,7 +588,7 @@ aff_combination_expand (aff_tree *comb A
type = TREE_TYPE (e);
name = e;
/* Look through some conversions. */
- if (TREE_CODE (e) == NOP_EXPR
+ if (CONVERT_EXPR_P (e)
&& (TYPE_PRECISION (type)
>= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (e, 0)))))
name = TREE_OPERAND (e, 0);
Index: gcc/tree-data-ref.c
===================================================================
--- gcc.orig/tree-data-ref.c 2009-08-06 08:00:59.000000000 +0200
+++ gcc/tree-data-ref.c 2009-09-29 15:33:23.000000000 +0200
@@ -1924,7 +1924,7 @@ initialize_matrix_A (lambda_matrix A, tr
return chrec_fold_op (TREE_CODE (chrec), chrec_type (chrec), op0, op1);
}
- case NOP_EXPR:
+ CASE_CONVERT:
{
tree op = initialize_matrix_A (A, TREE_OPERAND (chrec, 0), index, mult);
return chrec_convert (chrec_type (chrec), op, NULL);
Index: gcc/tree-inline.c
===================================================================
--- gcc.orig/tree-inline.c 2009-09-28 13:26:31.000000000 +0200
+++ gcc/tree-inline.c 2009-09-29 15:33:55.000000000 +0200
@@ -1505,7 +1505,7 @@ copy_bb (copy_body_data *id, basic_block
/* With return slot optimization we can end up with
non-gimple (foo *)&this->m, fix that here. */
if (is_gimple_assign (stmt)
- && gimple_assign_rhs_code (stmt) == NOP_EXPR
+ && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt))
&& !is_gimple_val (gimple_assign_rhs1 (stmt)))
{
tree new_rhs;
Index: gcc/tree-pretty-print.c
===================================================================
--- gcc.orig/tree-pretty-print.c 2009-09-15 15:02:55.000000000 +0200
+++ gcc/tree-pretty-print.c 2009-09-29 15:34:52.000000000 +0200
@@ -196,7 +196,7 @@ dump_decl_name (pretty_printer *buffer,
static void
dump_function_name (pretty_printer *buffer, tree node, int flags)
{
- if (TREE_CODE (node) == NOP_EXPR)
+ if (CONVERT_EXPR_P (node))
node = TREE_OPERAND (node, 0);
if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
@@ -2679,7 +2679,7 @@ print_call_name (pretty_printer *buffer,
case ADDR_EXPR:
case INDIRECT_REF:
- case NOP_EXPR:
+ CASE_CONVERT:
op0 = TREE_OPERAND (op0, 0);
goto again;
Index: gcc/tree-sra.c
===================================================================
--- gcc.orig/tree-sra.c 2009-09-20 22:05:01.000000000 +0200
+++ gcc/tree-sra.c 2009-09-29 15:35:22.000000000 +0200
@@ -3517,7 +3517,7 @@ sra_ipa_modify_expr (tree *expr, gimple_
|| TREE_CODE (*expr) == IMAGPART_EXPR
|| TREE_CODE (*expr) == REALPART_EXPR)
expr = &TREE_OPERAND (*expr, 0);
- while (TREE_CODE (*expr) == NOP_EXPR
+ while (CONVERT_EXPR_P (*expr)
|| TREE_CODE (*expr) == VIEW_CONVERT_EXPR)
expr = &TREE_OPERAND (*expr, 0);
Index: gcc/tree-ssa-forwprop.c
===================================================================
--- gcc.orig/tree-ssa-forwprop.c 2009-09-26 00:47:05.000000000 +0200
+++ gcc/tree-ssa-forwprop.c 2009-09-29 15:36:06.000000000 +0200
@@ -1167,7 +1167,7 @@ simplify_gimple_switch (gimple stmt)
def_stmt = SSA_NAME_DEF_STMT (cond);
if (is_gimple_assign (def_stmt))
{
- if (gimple_assign_rhs_code (def_stmt) == NOP_EXPR)
+ if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
{
int need_precision;
bool fail;
Index: gcc/tree-ssa-math-opts.c
===================================================================
--- gcc.orig/tree-ssa-math-opts.c 2009-07-01 12:56:16.000000000 +0200
+++ gcc/tree-ssa-math-opts.c 2009-09-29 15:36:39.000000000 +0200
@@ -993,8 +993,7 @@ find_bswap_1 (gimple stmt, struct symbol
&& code != RSHIFT_EXPR
&& code != LROTATE_EXPR
&& code != RROTATE_EXPR
- && code != NOP_EXPR
- && code != CONVERT_EXPR)
+ && !CONVERT_EXPR_CODE_P (code))
return NULL_TREE;
source_expr1 = find_bswap_1 (rhs1_stmt, n, limit - 1);
Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc.orig/tree-ssa-pre.c 2009-09-15 15:02:55.000000000 +0200
+++ gcc/tree-ssa-pre.c 2009-09-29 15:37:22.000000000 +0200
@@ -1227,7 +1227,7 @@ do_unary:
arg0->op0,
arg1 ? arg1->op0 : NULL);
if (folded
- && TREE_CODE (folded) == NOP_EXPR)
+ && CONVERT_EXPR_P (folded))
folded = TREE_OPERAND (folded, 0);
if (folded
&& is_gimple_min_invariant (folded))
Index: gcc/tree-vect-generic.c
===================================================================
--- gcc.orig/tree-vect-generic.c 2009-07-01 12:56:16.000000000 +0200
+++ gcc/tree-vect-generic.c 2009-09-29 15:37:56.000000000 +0200
@@ -417,14 +417,12 @@ expand_vector_operations_1 (gimple_stmt_
if (TREE_CODE (type) != VECTOR_TYPE)
return;
- if (code == NOP_EXPR
+ if (CONVERT_EXPR_CODE_P (code)
|| code == FLOAT_EXPR
|| code == FIX_TRUNC_EXPR
|| code == VIEW_CONVERT_EXPR)
return;
- gcc_assert (code != CONVERT_EXPR);
-
/* The signedness is determined from input argument. */
if (code == VEC_UNPACK_FLOAT_HI_EXPR
|| code == VEC_UNPACK_FLOAT_LO_EXPR)
Index: gcc/tree-vect-patterns.c
===================================================================
--- gcc.orig/tree-vect-patterns.c 2009-08-19 09:04:09.000000000 +0200
+++ gcc/tree-vect-patterns.c 2009-09-29 15:38:21.000000000 +0200
@@ -91,7 +91,7 @@ widened_name_p (tree name, gimple use_st
if (!is_gimple_assign (*def_stmt))
return false;
- if (gimple_assign_rhs_code (*def_stmt) != NOP_EXPR)
+ if (! CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (*def_stmt)))
return false;
oprnd0 = gimple_assign_rhs1 (*def_stmt);
Index: gcc/tree-vrp.c
===================================================================
--- gcc.orig/tree-vrp.c 2009-09-24 14:54:13.000000000 +0200
+++ gcc/tree-vrp.c 2009-09-29 15:41:01.000000000 +0200
@@ -1399,7 +1399,7 @@ extract_range_from_assert (value_range_t
/* Find VAR in the ASSERT_EXPR conditional. */
if (var == TREE_OPERAND (cond, 0)
|| TREE_CODE (TREE_OPERAND (cond, 0)) == PLUS_EXPR
- || TREE_CODE (TREE_OPERAND (cond, 0)) == NOP_EXPR)
+ || CONVERT_EXPR_P (TREE_OPERAND (cond, 0)))
{
/* If the predicate is of the form VAR COMP LIMIT, then we just
take LIMIT from the RHS and use the same comparison code. */
@@ -1461,7 +1461,7 @@ extract_range_from_assert (value_range_t
as well build the range [b_4, +INF] for it.
One special case we handle is extracting a range from a
range test encoded as (unsigned)var + CST <= limit. */
- if (TREE_CODE (cond) == NOP_EXPR
+ if (CONVERT_EXPR_P (cond)
|| TREE_CODE (cond) == PLUS_EXPR)
{
if (TREE_CODE (cond) == PLUS_EXPR)
@@ -4680,7 +4680,8 @@ find_assert_locations_1 (basic_block bb,
gimple def_stmt = SSA_NAME_DEF_STMT (t);
while (is_gimple_assign (def_stmt)
- && gimple_assign_rhs_code (def_stmt) == NOP_EXPR
+ && CONVERT_EXPR_CODE_P
+ (gimple_assign_rhs_code (def_stmt))
&& TREE_CODE
(gimple_assign_rhs1 (def_stmt)) == SSA_NAME
&& POINTER_TYPE_P
Index: gcc/tree.c
===================================================================
--- gcc.orig/tree.c 2009-09-28 17:47:20.000000000 +0200
+++ gcc/tree.c 2009-09-29 15:45:30.000000000 +0200
@@ -3547,7 +3547,7 @@ build1_stat (enum tree_code code, tree t
#endif
tree t;
- if (code == CONVERT_EXPR)
+ if (0 && code == CONVERT_EXPR)
code = NOP_EXPR;
#ifdef GATHER_STATISTICS
@@ -7593,7 +7593,7 @@ get_narrower (tree op, int *unsignedp_pt
tree win = op;
int typekind = kind_of_type (TREE_TYPE (op));
- while (TREE_CODE (op) == NOP_EXPR)
+ while (CONVERT_EXPR_P (op))
{
int bitschange
= (TYPE_PRECISION (TREE_TYPE (op))
Index: gcc/varasm.c
===================================================================
--- gcc.orig/varasm.c 2009-09-24 14:54:14.000000000 +0200
+++ gcc/varasm.c 2009-09-29 15:42:00.000000000 +0200
@@ -4449,7 +4449,7 @@ output_constant (tree exp, unsigned HOST
to the address of some declaration somewhere. If the target says
the mode is valid for pointers, assume the target has a way of
resolving it. */
- if (TREE_CODE (exp) == NOP_EXPR
+ if (CONVERT_EXPR_P (exp)
&& POINTER_TYPE_P (TREE_TYPE (exp))
&& targetm.valid_pointer_mode (TYPE_MODE (TREE_TYPE (exp))))
{
@@ -4457,7 +4457,7 @@ output_constant (tree exp, unsigned HOST
/* Peel off any intermediate conversions-to-pointer for valid
pointer modes. */
- while (TREE_CODE (exp) == NOP_EXPR
+ while (CONVERT_EXPR_P (exp)
&& POINTER_TYPE_P (TREE_TYPE (exp))
&& targetm.valid_pointer_mode (TYPE_MODE (TREE_TYPE (exp))))
exp = TREE_OPERAND (exp, 0);