It looks like it is safe to exchange both of them (the first one for sure)
to fold_convert (...) due to the fact that fold_unary handles NOP_EXPR
the same way than CONVERT_EXPR apart from cases that look like oversights,
f.i.
/* Convert (T1)((T2)X op Y) into (T1)X op Y, for pointer types T1
and
T2 being pointers to types of the same size. */
if (POINTER_TYPE_P (type)
&& BINARY_CLASS_P (arg0)
&& TREE_CODE (TREE_OPERAND (arg0, 0)) == NOP_EXPR
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (arg0, 0))))
{
or
case ABS_EXPR:
...
else if (TREE_CODE (arg0) == NOP_EXPR
&& TREE_CODE (type) == REAL_TYPE)
{
tree targ0 = strip_float_extensions (arg0);
if (targ0 != arg0)
return fold_convert (type, fold_build1 (ABS_EXPR,
TREE_TYPE (targ0),
targ0));
}
or
/* Simplify ((int)c & 0377) into (int)c, if c is unsigned char. */
if (TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (arg0) == NOP_EXPR
&& TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (arg0, 0))))
{
etc.
In fact, I remember a plan of merging NOP_EXPR and CONVERT_EXPR.
Is this correct?
Thanks,
Richard.