public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ftp.linux.org.uk>
To: Josh Triplett <josh@freedesktop.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: sparse -Wptr-subtraction-blows: still needed?
Date: Wed, 2 May 2007 01:26:43 +0100	[thread overview]
Message-ID: <20070502002643.GJ4095@ftp.linux.org.uk> (raw)
In-Reply-To: <4637D47D.7040203@freedesktop.org>

On Tue, May 01, 2007 at 04:59:57PM -0700, Josh Triplett wrote:
> Linus Torvalds wrote:
> > 
> > On Tue, 1 May 2007, Josh Triplett wrote:
> >> Does this still apply?  Do current versions of GCC still have this problem?
> >> If not, can the option and warning go away?
> > 
> > Even if current versions of gcc don't triple the build time (and for the 
> > kernel, I suspect it doesn't, because we've tried to clean up our header 
> > files), the generated _code_ will invariably suck.
> 
> "invariably"?
> 
> Do you know whether the current version of GCC generates poor code for pointer
> subtraction?
> 
> If so, does anything in particular make this an unfixable problem?

Just the fact that calculation itself is nasty.  In the best case you
get (on x86) something like
        sarl    $2, %eax
        imull   $-1431655765, %eax, %eax
(that one is with object size equal to 12).  On other targets it can get
considerably uglier - e.g. on alpha with -O2 the same will result in
        sra $17,2,$17
        s4subq $17,$17,$0
        s8subq $0,$0,$0
        s4addq $0,$17,$0
        sll $0,8,$1
        addq $0,$1,$0
        sll $0,16,$2
        addq $0,$2,$0
        sll $0,32,$1
        addq $0,$1,$0
        addq $0,$0,$0
        addl $0,$17,$0
With -Os it's
        ldah $1,$LC0($29)               !gprelhigh
        sra $0,2,$0
        ldq $1,$LC0($1)         !gprellow
        mull $0,$1,$0
with LC0 in rodata:
$LC0:
        .quad   -6148914691236517205

Now imagine the joy of having a bunch of such wonders in a hot path...

  parent reply	other threads:[~2007-05-02  0:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-01 21:08 sparse -Wptr-subtraction-blows: still needed? Josh Triplett
2007-05-01 21:43 ` Linus Torvalds
2007-05-01 23:59   ` Josh Triplett
2007-05-02  0:24     ` Linus Torvalds
2007-05-02  0:35       ` Al Viro
2007-05-02 12:02       ` Alan Cox
2007-05-02 13:19         ` Andi Kleen
2007-05-02  0:26     ` Al Viro [this message]
2007-05-02  0:02   ` Al Viro
2007-05-02  2:42   ` Dave Jones
2007-05-02 13:03     ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070502002643.GJ4095@ftp.linux.org.uk \
    --to=viro@ftp.linux.org.uk \
    --cc=josh@freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox