diff options
| -rw-r--r-- | gcc/ChangeLog | 5 | ||||
| -rw-r--r-- | gcc/expr.c | 18 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/20020108-1.c | 16 |
4 files changed, 37 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1151544e382..1b95cfe60c3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-01-08 Jakub Jelinek <jakub@redhat.com> + + * expr.c (store_expr): Convert VOIDmode constants back to target's + mode. + 2002-01-08 Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> * doc/invoke.texi: Markup gcc as @command. Refer to diff --git a/gcc/expr.c b/gcc/expr.c index 04d801de76f..d11df993c51 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -4041,13 +4041,19 @@ store_expr (exp, target, want_value) target. Otherwise, the caller might get confused by a result whose mode is larger than expected. */ - if (want_value && GET_MODE (temp) != GET_MODE (target) - && GET_MODE (temp) != VOIDmode) + if (want_value && GET_MODE (temp) != GET_MODE (target)) { - temp = gen_lowpart_SUBREG (GET_MODE (target), temp); - SUBREG_PROMOTED_VAR_P (temp) = 1; - SUBREG_PROMOTED_UNSIGNED_P (temp) - = SUBREG_PROMOTED_UNSIGNED_P (target); + if (GET_MODE (temp) != VOIDmode) + { + temp = gen_lowpart_SUBREG (GET_MODE (target), temp); + SUBREG_PROMOTED_VAR_P (temp) = 1; + SUBREG_PROMOTED_UNSIGNED_P (temp) + = SUBREG_PROMOTED_UNSIGNED_P (target); + } + else + temp = convert_modes (GET_MODE (target), + GET_MODE (SUBREG_REG (target)), + temp, SUBREG_PROMOTED_UNSIGNED_P (target)); } return want_value ? temp : NULL_RTX; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4b432d82204..d4f4a3ee075 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-01-08 Jakub Jelinek <jakub@redhat.com> + + * gcc.dg/20020108-1.c: New test. + 2002-01-08 H.J. Lu <hjl@gnu.org> * objc.dg/special/special.exp: Add -I${srcdir}/../../libobjc diff --git a/gcc/testsuite/gcc.dg/20020108-1.c b/gcc/testsuite/gcc.dg/20020108-1.c new file mode 100644 index 00000000000..b91022dc583 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20020108-1.c @@ -0,0 +1,16 @@ +/* This testcase failed on i686 because (const_int -1) was changed into + (const_int 0xffff) when storing it into SImode pseudo, but was not + converted back to (const_int -1) when returning from store_expr, + eventhough target was (subreg:HI (reg/v:SI indx)). But (const_int 0xffff) + is not valid general_operand in HImode. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mcpu=i686" { target i?86-*-* } } */ + +void +foo (unsigned short *cp) +{ + unsigned short indx; + + *cp = indx = 0xFFFF; +} |

