From d93d3864ca8a8b50de81e084136574021463d228 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 30 Aug 2017 11:18:20 +0000 Subject: [PATCH] [57/77] Use scalar_int_mode in expand_expr_addr_expr This patch rewrites the condition: if (tmode != address_mode && tmode != pointer_mode) tmode = address_mode; to the equivalent: tmode == pointer_mode ? pointer_mode : address_mode The latter has the advantage that the result is naturally a scalar_int_mode; a later mechanical patch makes it one. 2017-08-30 Richard Sandiford Alan Hayward David Sherwood gcc/ * expr.c (expand_expr_addr_expr): Add a new_tmode local variable that is always either address_mode or pointer_mode. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r251509 --- gcc/ChangeLog | 7 +++++++ gcc/expr.c | 13 +++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 15f951f78ba..51f6f374546 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-08-30 Richard Sandiford + Alan Hayward + David Sherwood + + * expr.c (expand_expr_addr_expr): Add a new_tmode local variable + that is always either address_mode or pointer_mode. + 2017-08-30 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/expr.c b/gcc/expr.c index cdebba35daa..481ad643956 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7910,20 +7910,21 @@ expand_expr_addr_expr (tree exp, rtx target, machine_mode tmode, /* We can get called with some Weird Things if the user does silliness like "(short) &a". In that case, convert_memory_address won't do the right thing, so ignore the given target mode. */ - if (tmode != address_mode && tmode != pointer_mode) - tmode = address_mode; + machine_mode new_tmode = (tmode == pointer_mode + ? pointer_mode + : address_mode); result = expand_expr_addr_expr_1 (TREE_OPERAND (exp, 0), target, - tmode, modifier, as); + new_tmode, modifier, as); /* Despite expand_expr claims concerning ignoring TMODE when not strictly convenient, stuff breaks if we don't honor it. Note that combined with the above, we only do this for pointer modes. */ rmode = GET_MODE (result); if (rmode == VOIDmode) - rmode = tmode; - if (rmode != tmode) - result = convert_memory_address_addr_space (tmode, result, as); + rmode = new_tmode; + if (rmode != new_tmode) + result = convert_memory_address_addr_space (new_tmode, result, as); return result; } -- 2.30.2