Message ID | 2905359.D6fWVlYKRA@polaris |
---|---|
State | New |
Headers | show |
On 05/14/14 04:40, Eric Botcazou wrote: > 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. Seems reasonable. Do you happen to have a testcase where you can see the effects in one of the dumps? Jeff
> Seems reasonable. Do you happen to have a testcase where you can see > the effects in one of the dumps? That's not easy because NON_LVALUE_EXPRs are present only in .original and, at least in Ada, essentially only in size expressions which are not visible in the dump.
On 05/15/14 08:15, Eric Botcazou wrote: >> Seems reasonable. Do you happen to have a testcase where you can see >> the effects in one of the dumps? > > That's not easy because NON_LVALUE_EXPRs are present only in .original and, at > least in Ada, essentially only in size expressions which are not visible in > the dump. OK. Just thought I'd verify in case it'd been forgotten. jeff
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: