calls.c (shift_returned_value): Fix handling of non-integer TYPE_MODEs.
authorRichard Sandiford <rsandifo@redhat.com>
Thu, 24 Jun 2004 15:30:07 +0000 (15:30 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 24 Jun 2004 15:30:07 +0000 (15:30 +0000)
* calls.c (shift_returned_value): Fix handling of non-integer
TYPE_MODEs.

From-SVN: r83595

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20040624-1.c [new file with mode: 0644]

index e8b77275bbd0caa53cacec833f761b643e424553..d50d7f061b5d51c4bdac2e738a621bbf75e685d9 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-24  Richard Sandiford  <rsandifo@redhat.com>
+
+       * calls.c (shift_returned_value): Fix handling of non-integer
+       TYPE_MODEs.
+
 2004-06-24  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * c-decl.c (finish_function): Do not check for DEFAULT_MAIN_RETURN.
index 80931003f92193db38bb57ebe8ee9d8c72b0ef2e..ccefb54992c224088005ee2c6f86bcc603a40adf 100644 (file)
@@ -1920,9 +1920,17 @@ shift_returned_value (tree type, rtx *value)
               - BITS_PER_UNIT * int_size_in_bytes (type));
       if (shift > 0)
        {
+         /* Shift the value into the low part of the register.  */
          *value = expand_binop (GET_MODE (*value), lshr_optab, *value,
                                 GEN_INT (shift), 0, 1, OPTAB_WIDEN);
-         *value = convert_to_mode (TYPE_MODE (type), *value, 0);
+
+         /* Truncate it to the type's mode, or its integer equivalent.
+            This is subject to TRULY_NOOP_TRUNCATION.  */
+         *value = convert_to_mode (int_mode_for_mode (TYPE_MODE (type)),
+                                   *value, 0);
+
+         /* Now convert it to the final form.  */
+         *value = gen_lowpart (TYPE_MODE (type), *value);
          return true;
        }
     }
index 539cd97951d84911d50d76ddab50a2f8d538a828..07f99b51338b9fdb1d16f56a23a854613591e628 100644 (file)
@@ -1,3 +1,7 @@
+2004-06-24  Richard Sandiford  <rsandifo@redhat.com>
+
+       * gcc.c-torture/compile/20040624-1.c: New test.
+
 2004-06-24  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        * g++.dg/tree-ssa/tree-ssa.exp: Remove. dg.exp already handles
diff --git a/gcc/testsuite/gcc.c-torture/compile/20040624-1.c b/gcc/testsuite/gcc.c-torture/compile/20040624-1.c
new file mode 100644 (file)
index 0000000..8eb92a4
--- /dev/null
@@ -0,0 +1,3 @@
+struct s { float f[1]; };
+struct s foo();
+float bar() { return foo().f[0]; }