OSDN Git Service

* calls.c (emit_library_call_value_1): If PROMOTE_MODE modifed the
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Feb 2007 18:46:16 +0000 (18:46 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Feb 2007 18:46:16 +0000 (18:46 +0000)
        result mode of the libcall, convert back to outmode.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121852 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/calls.c

index 486cd93..e23a321 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 53e4d3f..1f8ed60 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)