public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/41302]  New: Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn.
@ 2009-09-07 22:24 dferbas at etech dot cz
  2009-09-09 22:14 ` [Bug target/41302] " rth at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dferbas at etech dot cz @ 2009-09-07 22:24 UTC (permalink / raw)
  To: gcc-bugs

Called fn returns value in d0 (non pointer), but findZipEntry should return
value in a0 (address register). So in that case optimization cannot be done by
simply jumping to the called fn.

typedef u_int32_t       w_word;
typedef struct *        z_zipEntry;

z_zipEntry findZipEntry(z_zipFile dir, w_byte *name) {

        return (z_zipEntry) ht_read(dir->ht, (w_word)name);
}


findZipEntry:
        move.l 4(%sp),%a0
        move.l 8(%a0),4(%sp)

        jra ht_read

There should be:
        jbsr ht_read
        move.l %d0,%a0
        rts


-- 
           Summary: Cast of return value from uint32 to pointer cannot be
                    optimized by a jump to called rtn.
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dferbas at etech dot cz


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41302


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/41302] Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn.
  2009-09-07 22:24 [Bug c/41302] New: Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn dferbas at etech dot cz
@ 2009-09-09 22:14 ` rth at gcc dot gnu dot org
  2009-09-22 22:39 ` dferbas at etech dot cz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rth at gcc dot gnu dot org @ 2009-09-09 22:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rth at gcc dot gnu dot org  2009-09-09 22:14 -------
This is almost certainly a bug in the m68k backend in that it
doesn't check for the difference in return registers.  Compare
it's m68k_ok_for_sibcall_p function vs the i386 routine.


-- 

rth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41302


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/41302] Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn.
  2009-09-07 22:24 [Bug c/41302] New: Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn dferbas at etech dot cz
  2009-09-09 22:14 ` [Bug target/41302] " rth at gcc dot gnu dot org
@ 2009-09-22 22:39 ` dferbas at etech dot cz
  2009-10-30 10:16 ` mkuvyrkov at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dferbas at etech dot cz @ 2009-09-22 22:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dferbas at etech dot cz  2009-09-22 22:39 -------
We tried to modify the m68k variant of sibcall fn. But we have a problem with
compilation. Is there anyone who can test if following is OK ?

/* Implement TARGET_FUNCTION_OK_FOR_SIBCALL_P.  We cannot use sibcalls
   for nested functions because we use the static chain register for
   indirect calls.  */


static bool
m68k_ok_for_sibcall_p (tree decl, tree exp)
{
  tree func;
  rtx a, b;

  enum m68k_function_kind kind;


  if (TREE_OPERAND (exp, 2))
    return false;


  /* --- incorporated from x386 ---
   * This addresses issue when 1 fn returns a pointer in an address  
register
   * it is casted and the other fn returns a value in data register. */
  if (decl)
    func = decl;
  else
    {
      func = TREE_TYPE (TREE_OPERAND (exp, 0));
      if (POINTER_TYPE_P (func))
        func = TREE_TYPE (func);
    }

  /* Check that the return value locations are the same.  Like
     if we are returning floats on the 80387 register stack, we cannot
     make a sibcall from a function that doesn't return a float to a
     function that does or, conversely, from a function that does return
     a float to a function that doesn't; the necessary stack adjustment
     would not be executed.  This is also the place we notice
     differences in the return value ABI.  Note that it is ok for one
     of the functions to have void return type as long as the return
     value of the other is passed in a register.  */
  a = m68k_function_value (TREE_TYPE (exp), func);
  b = m68k_function_value (TREE_TYPE (DECL_RESULT (current_function_decl)),
                           current_function_decl);


  if (VOID_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl))))
  ;
  else if (!rtx_equal_p (a, b))
    return false;       
  /* --- */


  kind = m68k_get_function_kind (current_function_decl);
  if (kind == m68k_fk_normal_function)
    /* We can always sibcall from a normal function, because it's
       undefined if it is calling an interrupt function.  */
    return true;


  /* Otherwise we can only sibcall if the function kind is known to be
     the same.  */
  if (decl && m68k_get_function_kind (decl) == kind)
    return true;


  return false;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41302


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/41302] Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn.
  2009-09-07 22:24 [Bug c/41302] New: Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn dferbas at etech dot cz
  2009-09-09 22:14 ` [Bug target/41302] " rth at gcc dot gnu dot org
  2009-09-22 22:39 ` dferbas at etech dot cz
@ 2009-10-30 10:16 ` mkuvyrkov at gcc dot gnu dot org
  2009-11-04  9:58 ` mkuvyrkov at gcc dot gnu dot org
  2009-11-04 11:47 ` mkuvyrkov at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mkuvyrkov at gcc dot gnu dot org @ 2009-10-30 10:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mkuvyrkov at gcc dot gnu dot org  2009-10-30 10:16 -------
Patch posted at http://gcc.gnu.org/ml/gcc-patches/2009-10/msg01790.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41302


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/41302] Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn.
  2009-09-07 22:24 [Bug c/41302] New: Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn dferbas at etech dot cz
                   ` (2 preceding siblings ...)
  2009-10-30 10:16 ` mkuvyrkov at gcc dot gnu dot org
@ 2009-11-04  9:58 ` mkuvyrkov at gcc dot gnu dot org
  2009-11-04 11:47 ` mkuvyrkov at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mkuvyrkov at gcc dot gnu dot org @ 2009-11-04  9:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from mkuvyrkov at gcc dot gnu dot org  2009-11-04 09:58 -------
Subject: Bug 41302

Author: mkuvyrkov
Date: Wed Nov  4 09:57:55 2009
New Revision: 153890

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153890
Log:
2009-11-04  Maxim Kuvyrkov  <maxim@codesourcery.com>

        PR target/41302
        * config/m68k/m68k.c (m68k_reg_present_p): New static function.
        (m68k_ok_for_sibcall_p): Handle different result return locations.

2009-11-04  Carlos O'Donell  <carlos@codesourcery.com>

        PR target/41302
        * gcc.target/m68k/pr41302.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/m68k/pr41302.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/m68k/m68k.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41302


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/41302] Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn.
  2009-09-07 22:24 [Bug c/41302] New: Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn dferbas at etech dot cz
                   ` (3 preceding siblings ...)
  2009-11-04  9:58 ` mkuvyrkov at gcc dot gnu dot org
@ 2009-11-04 11:47 ` mkuvyrkov at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mkuvyrkov at gcc dot gnu dot org @ 2009-11-04 11:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mkuvyrkov at gcc dot gnu dot org  2009-11-04 11:47 -------
Fixed.


-- 

mkuvyrkov at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41302


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-11-04 11:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-07 22:24 [Bug c/41302] New: Cast of return value from uint32 to pointer cannot be optimized by a jump to called rtn dferbas at etech dot cz
2009-09-09 22:14 ` [Bug target/41302] " rth at gcc dot gnu dot org
2009-09-22 22:39 ` dferbas at etech dot cz
2009-10-30 10:16 ` mkuvyrkov at gcc dot gnu dot org
2009-11-04  9:58 ` mkuvyrkov at gcc dot gnu dot org
2009-11-04 11:47 ` mkuvyrkov at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).