aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2015-04-14 16:12:34 +0000
committerNick Clifton <nickc@gcc.gnu.org>2015-04-14 16:12:34 +0000
commit5751fb330d8edb4ee61dcf66a19adb98bec5cf37 (patch)
tree53436624eab879ce27cfe6fc7c6f19abf6c43bb0 /gcc/expr.c
parentfb899e32c16088cad1a19a3e8df615ecfd1332db (diff)
downloadgcc-5751fb330d8edb4ee61dcf66a19adb98bec5cf37.zip
gcc-5751fb330d8edb4ee61dcf66a19adb98bec5cf37.tar.gz
gcc-5751fb330d8edb4ee61dcf66a19adb98bec5cf37.tar.bz2
expr.c (expand_assignment): Force an address offset computation into a register before changing its mode.
* expr.c (expand_assignment): Force an address offset computation into a register before changing its mode. (expand_expr_real_1): Likewise. From-SVN: r222098
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 5c09550..530a944 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -4879,7 +4879,13 @@ expand_assignment (tree to, tree from, bool nontemporal)
offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, EXPAND_SUM);
address_mode = get_address_mode (to_rtx);
if (GET_MODE (offset_rtx) != address_mode)
- offset_rtx = convert_to_mode (address_mode, offset_rtx, 0);
+ {
+ /* We cannot be sure that the RTL in offset_rtx is valid outside
+ of a memory address context, so force it into a register
+ before attempting to convert it to the desired mode. */
+ offset_rtx = force_operand (offset_rtx, NULL_RTX);
+ offset_rtx = convert_to_mode (address_mode, offset_rtx, 0);
+ }
/* If we have an expression in OFFSET_RTX and a non-zero
byte offset in BITPOS, adding the byte offset before the
@@ -10258,7 +10264,13 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
address_mode = get_address_mode (op0);
if (GET_MODE (offset_rtx) != address_mode)
- offset_rtx = convert_to_mode (address_mode, offset_rtx, 0);
+ {
+ /* We cannot be sure that the RTL in offset_rtx is valid outside
+ of a memory address context, so force it into a register
+ before attempting to convert it to the desired mode. */
+ offset_rtx = force_operand (offset_rtx, NULL_RTX);
+ offset_rtx = convert_to_mode (address_mode, offset_rtx, 0);
+ }
/* See the comment in expand_assignment for the rationale. */
if (mode1 != VOIDmode