This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Minor improvement to fold_unary_loc
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 14 May 2014 12:40:53 +0200
- Subject: [patch] Minor improvement to fold_unary_loc
- Authentication-results: sourceware.org; auth=none
Hi,
this makes fold_unary_loc fold NON_LVALUE_EXPR if the argument cannot be a
lvalue (this happens when you're re-fold-building an existing tree) and
changes the first call to fold_convert_const to use arg0 instead of op0, like
the other 2 calls just below (this should not change anything if the argument
is correctly folded, but is more forgiving if it is not).
Tested on x86_64-suse-linux, OK for the mainline?
2014-05-14 Eric Botcazou <ebotcazou@adacore.com>
* fold-const (fold_unary_loc) <NON_LVALUE_EXPR>: New case.
<CASE_CONVERT>: Pass arg0 instead of op0 to fold_convert_const.
--
Eric Botcazou
Index: fold-const.c
===================================================================
--- fold-const.c (revision 210410)
+++ fold-const.c (working copy)
@@ -7850,6 +7850,11 @@ fold_unary_loc (location_t loc, enum tre
return fold_convert_loc (loc, type, op0);
return NULL_TREE;
+ case NON_LVALUE_EXPR:
+ if (!maybe_lvalue_p (op0))
+ return fold_convert_loc (loc, type, op0);
+ return NULL_TREE;
+
CASE_CONVERT:
case FLOAT_EXPR:
case FIX_TRUNC_EXPR:
@@ -8113,7 +8118,7 @@ fold_unary_loc (location_t loc, enum tre
}
}
- tem = fold_convert_const (code, type, op0);
+ tem = fold_convert_const (code, type, arg0);
return tem ? tem : NULL_TREE;
case ADDR_SPACE_CONVERT_EXPR: