]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
calls.c (emit_library_call_value_1): If PROMOTE_MODE modifed the result mode of the...
authorRichard Henderson <rth@redhat.com>
Mon, 12 Feb 2007 18:46:16 +0000 (10:46 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Mon, 12 Feb 2007 18:46:16 +0000 (10:46 -0800)
        * calls.c (emit_library_call_value_1): If PROMOTE_MODE modifed the
        result mode of the libcall, convert back to outmode.

From-SVN: r121852

gcc/ChangeLog
gcc/calls.c

index 486cd9358f8a828da4330b6c89637b29dde9624f..e23a321898a9bf52ecb83b9e01f1d6160e6e1b2d 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-12  Richard Henderson  <rth@redhat.com>
+
+       * calls.c (emit_library_call_value_1): If PROMOTE_MODE modifed the
+       result mode of the libcall, convert back to outmode.
+
 2007-02-12  Roger Sayle  <roger@eyesopen.com>
 
        * config/i386/i386.md (*bswapdi2_rex): Renamed from bswapdi2.
index 53e4d3f073d5b1d483c414441a222b009cc9e003..1f8ed60bf12cf1a02ec919809d61ca539f7feddc 100644 (file)
@@ -3916,10 +3916,25 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
            value = gen_reg_rtx (outmode);
          emit_group_store (value, valreg, NULL_TREE, GET_MODE_SIZE (outmode));
        }
-      else if (value != 0)
-       emit_move_insn (value, valreg);
       else
-       value = valreg;
+       {
+         /* Convert to the proper mode if PROMOTE_MODE has been active.  */
+         if (GET_MODE (valreg) != outmode)
+           {
+             int unsignedp = TYPE_UNSIGNED (tfom);
+
+             gcc_assert (targetm.calls.promote_function_return (tfom));
+             gcc_assert (promote_mode (tfom, outmode, &unsignedp, 0)
+                         == GET_MODE (valreg));
+
+             valreg = convert_modes (outmode, GET_MODE (valreg), valreg, 0);
+           }
+
+         if (value != 0)
+           emit_move_insn (value, valreg);
+         else
+           value = valreg;
+       }
     }
 
   if (ACCUMULATE_OUTGOING_ARGS)