(expand_call): Always allocate TARGET in mode of result expression;
authorRichard Kenner <kenner@gcc.gnu.org>
Mon, 29 Mar 1993 01:26:03 +0000 (20:26 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Mon, 29 Mar 1993 01:26:03 +0000 (20:26 -0500)
VALREG might have been promoted.
Ensure TARGET is a REG when checking for promotion and verify that we
get back the mode we expect.

From-SVN: r3907

gcc/calls.c

index 1d6837eb7af34aa94043ab138072ae517e8c70b7..14b2000161b1fc4a466f6132f751ea116a9e7b3a 100644 (file)
@@ -1834,10 +1834,12 @@ expand_call (exp, target, ignore)
     target = copy_to_reg (valreg);
 
 #ifdef PROMOTE_FUNCTION_RETURN
-  /* If we promoted this return value, make the proper SUBREG.  */
-  if (GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
+  /* If we promoted this return value, make the proper SUBREG.  TARGET
+     might be const0_rtx here, so be careful.  */
+  if (GET_CODE (target) == REG
+      && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
     {
-      enum machine_mode mode = GET_MODE (target);
+      enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
       int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
 
       if (TREE_CODE (TREE_TYPE (exp)) == INTEGER_TYPE
@@ -1851,6 +1853,10 @@ expand_call (exp, target, ignore)
          PROMOTE_MODE (mode, unsignedp, TREE_TYPE (exp));
        }
 
+      /* If we didn't promote as expected, something is wrong.  */
+      if (mode != GET_MODE (target))
+       abort ();
+
       target = gen_rtx (SUBREG, TYPE_MODE (TREE_TYPE (exp)), target, 0);
       SUBREG_PROMOTED_VAR_P (target) = 1;
       SUBREG_PROMOTED_UNSIGNED_P (target) = unsignedp;