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.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 3fdfb92..6a00abe 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6148,7 +6148,8 @@ fold_sign_changed_comparison (enum tree_code code, tree type,
tree arg0_inner, tmp;
tree inner_type, outer_type;
- if (TREE_CODE (arg0) != NOP_EXPR)
+ if (TREE_CODE (arg0) != NOP_EXPR
+ && TREE_CODE (arg0) != CONVERT_EXPR)
return NULL_TREE;
outer_type = TREE_TYPE (arg0);
@@ -6159,7 +6160,8 @@ fold_sign_changed_comparison (enum tree_code code, tree type,
return NULL_TREE;
if (TREE_CODE (arg1) != INTEGER_CST
- && !(TREE_CODE (arg1) == NOP_EXPR
+ && !((TREE_CODE (arg1) == NOP_EXPR
+ || TREE_CODE (arg1) == CONVERT_EXPR)
&& TREE_TYPE (TREE_OPERAND (arg1, 0)) == inner_type))
return NULL_TREE;
@@ -6180,7 +6182,7 @@ fold_sign_changed_comparison (enum tree_code code, tree type,
else
arg1 = fold_convert (inner_type, arg1);
- return fold (build (code, type, arg0_inner, arg1));
+ return fold (build2 (code, type, arg0_inner, arg1));
}
/* Tries to replace &a[idx] CODE s * delta with &a[idx CODE delta], if s is
@@ -9150,7 +9152,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
TREE_OPERAND (arg0, 0), TREE_OPERAND (arg0, 1)));
else if (TREE_CODE (TREE_TYPE (arg0)) == INTEGER_TYPE
- && TREE_CODE (arg0) == NOP_EXPR)
+ && (TREE_CODE (arg0) == NOP_EXPR
+ || TREE_CODE (arg0) == CONVERT_EXPR))
{
/* If we are widening one operand of an integer comparison,
see if the other operand is similarly being widened. Perhaps we