aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 8519e68..22350b9 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8247,7 +8247,12 @@ fold_unary (enum tree_code code, tree type, tree op0)
case VIEW_CONVERT_EXPR:
if (TREE_TYPE (op0) == type)
return op0;
- if (TREE_CODE (op0) == VIEW_CONVERT_EXPR)
+ if (TREE_CODE (op0) == VIEW_CONVERT_EXPR
+ || (TREE_CODE (op0) == NOP_EXPR
+ && INTEGRAL_TYPE_P (TREE_TYPE (op0))
+ && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (op0, 0)))
+ && TYPE_PRECISION (TREE_TYPE (op0))
+ == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))))
return fold_build1 (VIEW_CONVERT_EXPR, type, TREE_OPERAND (op0, 0));
return fold_view_convert_expr (type, op0);