aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1992-12-27 03:55:29 +0000
committerRichard Stallman <rms@gnu.org>1992-12-27 03:55:29 +0000
commitf5df292efc42b912b8babdd3593545fa3ec0842c (patch)
treea470983d15aef01440ea07de263ad3c9c3f8ee32
parent66212c2f764860e8b40ec23c1a45b9bf754c5354 (diff)
downloadgcc-f5df292efc42b912b8babdd3593545fa3ec0842c.zip
gcc-f5df292efc42b912b8babdd3593545fa3ec0842c.tar.gz
gcc-f5df292efc42b912b8babdd3593545fa3ec0842c.tar.bz2
(store_bit_field): If VALUE needs to be narrowed, do
it with gen_lowpart, not an explicit SUBREG. From-SVN: r2920
-rw-r--r--gcc/expmed.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 5819ce4..2c95a86 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -402,12 +402,18 @@ store_bit_field (str_rtx, bitsize, bitnum, fieldmode, value, align, total_size)
if (GET_MODE_BITSIZE (GET_MODE (value)) >= bitsize)
{
/* Optimization: Don't bother really extending VALUE
- if it has all the bits we will actually use. */
+ if it has all the bits we will actually use. However,
+ if we must narrow it, be sure we do it correctly. */
- /* Avoid making subreg of a subreg, or of a mem. */
- if (GET_CODE (value1) != REG)
+ if (GET_MODE_SIZE (GET_MODE (value)) < GET_MODE_SIZE (maxmode))
+ {
+ /* Avoid making subreg of a subreg, or of a mem. */
+ if (GET_CODE (value1) != REG)
value1 = copy_to_reg (value1);
- value1 = gen_rtx (SUBREG, maxmode, value1, 0);
+ value1 = gen_rtx (SUBREG, maxmode, value1, 0);
+ }
+ else
+ value1 = gen_lowpart (maxmode, value1);
}
else if (!CONSTANT_P (value))
/* Parse phase is supposed to make VALUE's data type