Commit d93d3864 by Richard Sandiford Committed by Richard Sandiford

[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  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

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 <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r251509
parent 8a92a3f3
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* 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 <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* expr.c (expand_expr_real_2): Use word_mode instead of innermode * expr.c (expand_expr_real_2): Use word_mode instead of innermode
when the two are known to be equal. when the two are known to be equal.
......
...@@ -7910,20 +7910,21 @@ expand_expr_addr_expr (tree exp, rtx target, machine_mode tmode, ...@@ -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 /* 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 like "(short) &a". In that case, convert_memory_address won't do
the right thing, so ignore the given target mode. */ the right thing, so ignore the given target mode. */
if (tmode != address_mode && tmode != pointer_mode) machine_mode new_tmode = (tmode == pointer_mode
tmode = address_mode; ? pointer_mode
: address_mode);
result = expand_expr_addr_expr_1 (TREE_OPERAND (exp, 0), target, 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 /* Despite expand_expr claims concerning ignoring TMODE when not
strictly convenient, stuff breaks if we don't honor it. Note strictly convenient, stuff breaks if we don't honor it. Note
that combined with the above, we only do this for pointer modes. */ that combined with the above, we only do this for pointer modes. */
rmode = GET_MODE (result); rmode = GET_MODE (result);
if (rmode == VOIDmode) if (rmode == VOIDmode)
rmode = tmode; rmode = new_tmode;
if (rmode != tmode) if (rmode != new_tmode)
result = convert_memory_address_addr_space (tmode, result, as); result = convert_memory_address_addr_space (new_tmode, result, as);
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment