public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16172] New: simple function generates an inappropriate memmove() call
@ 2004-06-24  8:06 akpm at osdl dot org
  2004-06-24  8:11 ` [Bug middle-end/16172] [3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: akpm at osdl dot org @ 2004-06-24  8:06 UTC (permalink / raw)
  To: gcc-bugs

compiling http://www.zip.com.au/~akpm/linux/patches/stuff/fib_hash.i

with

/usr/local/gcc-cvs/bin/gcc -Wp,-MD,net/ipv4/.fib_hash.o.d -nostdinc -iwithprefix
include -D__KERNEL__ -Iinclude  -Wall -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -pipe -msoft-float -mpreferred-stack-boundary=2
-fno-unit-at-a-time -march=i686 -mregparm=3 -Iinclude/asm-i386/mach-default
-gdwarf-2 -O1 -Os -g -Wdeclaration-after-statement    -DKBUILD_BASENAME=fib_hash
-DKBUILD_MODNAME=fib_hash -c -o net/ipv4/.tmp_fib_hash.o net/ipv4/fib_hash.c

causes the fn_hash() function to generate a call to memmove().  It seems
inappropriate, as that function deals with little scalars.

-- 
           Summary: simple function generates an inappropriate memmove()
                    call
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: akpm at osdl dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: gcc version 3.5.0 20040623 (experimental)
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug middle-end/16172] [3.5 Regression] simple function generates an inappropriate memmove() call
  2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
@ 2004-06-24  8:11 ` pinskia at gcc dot gnu dot org
  2004-06-24  8:52 ` falk at debian dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-24  8:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-24 08:06 -------
This does not make sense:
 return *(fn_hash_idx_t*)&h;
why do it this way, to get NRV to work well for 3.5.0 this is not needed at all and is what caused the 
problem, also this is undefined by the C standard (but we define it with -fno-strict-aliasing but this just 
makes the code ugly to look at).
Also why have it return a struct in the first place this seems dumb.
Anyways a workaround (maybe even a real fix):
 fn_hash_idx_t t;
 t.datum = h;
 return t;
But anyways the call to memmove is a regression.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end
           Keywords|                            |missed-optimization
            Summary|simple function generates an|[3.5 Regression] simple
                   |inappropriate memmove() call|function generates an
                   |                            |inappropriate memmove() call
   Target Milestone|---                         |3.5.0


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


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

* [Bug middle-end/16172] [3.5 Regression] simple function generates an inappropriate memmove() call
  2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
  2004-06-24  8:11 ` [Bug middle-end/16172] [3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-06-24  8:52 ` falk at debian dot org
  2004-06-24 15:31 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: falk at debian dot org @ 2004-06-24  8:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2004-06-24 08:52 -------
Just for the record, here's a test case:

struct fn_hash_idx_t {
  unsigned datum;
};

struct fn_hash_idx_t
fn_hash(unsigned h)
{
  return *(struct fn_hash_idx_t*)&h;
}

-- 


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


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

* [Bug middle-end/16172] [3.5 Regression] simple function generates an inappropriate memmove() call
  2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
  2004-06-24  8:11 ` [Bug middle-end/16172] [3.5 Regression] " pinskia at gcc dot gnu dot org
  2004-06-24  8:52 ` falk at debian dot org
@ 2004-06-24 15:31 ` pinskia at gcc dot gnu dot org
  2004-06-28  2:11 ` [Bug middle-end/16172] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-24 15:31 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-06-24 15:14:29
               date|                            |


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


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

* [Bug middle-end/16172] simple function generates an inappropriate memmove() call
  2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
                   ` (2 preceding siblings ...)
  2004-06-24 15:31 ` pinskia at gcc dot gnu dot org
@ 2004-06-28  2:11 ` pinskia at gcc dot gnu dot org
  2004-10-31  3:28 ` roger at eyesopen dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-28  2:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-28 02:03 -------
Actually the memmove is not a regression at all, the inlining of the function is though.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |2.95.3 3.3.3 3.0.4 3.4.0
                   |                            |3.5.0 3.2.3
            Summary|[3.5 Regression] simple     |simple function generates an
                   |function generates an       |inappropriate memmove() call
                   |inappropriate memmove() call|
   Target Milestone|3.5.0                       |---


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


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

* [Bug middle-end/16172] simple function generates an inappropriate memmove() call
  2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
                   ` (3 preceding siblings ...)
  2004-06-28  2:11 ` [Bug middle-end/16172] " pinskia at gcc dot gnu dot org
@ 2004-10-31  3:28 ` roger at eyesopen dot com
  2004-10-31  4:35 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: roger at eyesopen dot com @ 2004-10-31  3:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From roger at eyesopen dot com  2004-10-31 03:28 -------
I'm unable to reproduce this using Falk's testcase in comment #2, and the
original URL is now a broken link.  Has the problem now been fixed, or
could someone attach a failing testcase to the bugzilla PR.  Please? TIA


-- 


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


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

* [Bug middle-end/16172] simple function generates an inappropriate memmove() call
  2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
                   ` (4 preceding siblings ...)
  2004-10-31  3:28 ` roger at eyesopen dot com
@ 2004-10-31  4:35 ` pinskia at gcc dot gnu dot org
  2005-01-13 19:25 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-31  4:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-31 04:35 -------
I can still reproduce it with Falk's testcase on powerpc-darwin on the mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|gcc version 3.5.0 20040623  |
                   |(experimental)              |
   GCC host triplet|i686-pc-linux-gnu           |


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


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

* [Bug middle-end/16172] simple function generates an inappropriate memmove() call
  2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
                   ` (5 preceding siblings ...)
  2004-10-31  4:35 ` pinskia at gcc dot gnu dot org
@ 2005-01-13 19:25 ` pinskia at gcc dot gnu dot org
  2005-04-06 17:31 ` [Bug middle-end/16172] simple function generates an memmove() call instead of inlining pinskia at gcc dot gnu dot org
  2005-06-13  3:58 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-13 19:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-13 19:25 -------
Here is a testcase which I can reproduce it with on powerpc-darwin (it just has more elements in the 
struct):
struct fn_hash_idx_t {
  unsigned datum;
  unsigned datum2;
  unsigned datum3;
  unsigned datumi4;
  unsigned datum5;
  unsigned datum6;
  unsigned datum7;
  unsigned datum8;
  unsigned datum9;
};

struct fn_hash_idx_t
fn_hash(unsigned h)
{
  return *(struct fn_hash_idx_t*)&h;
}

-- 


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


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

* [Bug middle-end/16172] simple function generates an memmove() call instead of inlining
  2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
                   ` (6 preceding siblings ...)
  2005-01-13 19:25 ` pinskia at gcc dot gnu dot org
@ 2005-04-06 17:31 ` pinskia at gcc dot gnu dot org
  2005-06-13  3:58 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-06 17:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-06 17:31 -------
Note I don't think it is an inappropiate call to memmove.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|simple function generates an|simple function generates an
                   |inappropriate memmove() call|memmove() call instead of
                   |                            |inlining


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


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

* [Bug middle-end/16172] simple function generates an memmove() call instead of inlining
  2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
                   ` (7 preceding siblings ...)
  2005-04-06 17:31 ` [Bug middle-end/16172] simple function generates an memmove() call instead of inlining pinskia at gcc dot gnu dot org
@ 2005-06-13  3:58 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-13  3:58 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement
   Last reconfirmed|2004-06-24 15:14:29         |2005-06-13 03:58:53
               date|                            |


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


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

* [Bug middle-end/16172] simple function generates an memmove() call instead of inlining
       [not found] <bug-16172-4@http.gcc.gnu.org/bugzilla/>
@ 2022-12-01  3:35 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-01  3:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16172

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |4.1.0
         Resolution|---                         |FIXED
      Known to fail|                            |

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The original testcase (in comment #2 as the fib_hash.i is gone) has been fixed
for a long time now. At least GCC 4.1.2.

So closing as fixed.

Starting in GCC 10, the testcase produces even smaller code:
fn_hash:
.LFB0:
        .cfi_startproc
        movl    %edx, (%eax)
        ret

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

end of thread, other threads:[~2022-12-01  3:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-24  8:06 [Bug c/16172] New: simple function generates an inappropriate memmove() call akpm at osdl dot org
2004-06-24  8:11 ` [Bug middle-end/16172] [3.5 Regression] " pinskia at gcc dot gnu dot org
2004-06-24  8:52 ` falk at debian dot org
2004-06-24 15:31 ` pinskia at gcc dot gnu dot org
2004-06-28  2:11 ` [Bug middle-end/16172] " pinskia at gcc dot gnu dot org
2004-10-31  3:28 ` roger at eyesopen dot com
2004-10-31  4:35 ` pinskia at gcc dot gnu dot org
2005-01-13 19:25 ` pinskia at gcc dot gnu dot org
2005-04-06 17:31 ` [Bug middle-end/16172] simple function generates an memmove() call instead of inlining pinskia at gcc dot gnu dot org
2005-06-13  3:58 ` pinskia at gcc dot gnu dot org
     [not found] <bug-16172-4@http.gcc.gnu.org/bugzilla/>
2022-12-01  3:35 ` pinskia at gcc dot gnu.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).