From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Subject: Re: [RFC][PATCH 2/3] math128: Introduce {mult,add,cmp}_u128 Date: Tue, 24 Apr 2012 18:46:14 -0700 Message-ID: References: <20120424161039.293018424@chello.nl> <20120424162224.526249106@chello.nl> <1335304497.28150.243.camel@twins> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <1335304497.28150.243.camel@twins> Sender: linux-kernel-owner@vger.kernel.org To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Andrew Morton , Juri Lelli , Ingo Molnar , Thomas Gleixner List-Id: linux-arch.vger.kernel.org On Tue, Apr 24, 2012 at 2:54 PM, Peter Zijlstra wrote: > > that does generate slightly better code in that it avoids some masks = on > 64bit: > > @@ -7,12 +7,11 @@ > =A0.LFB38: > =A0 =A0 =A0 =A0.cfi_startproc > =A0 =A0 =A0 =A0movq =A0 =A0%rdi, %r8 > - =A0 =A0 =A0 movq =A0 =A0%rdi, %rdx > =A0 =A0 =A0 =A0movq =A0 =A0%rsi, %rcx > + =A0 =A0 =A0 mov =A0 =A0 %edi, %edx > =A0 =A0 =A0 =A0shrq =A0 =A0$32, %r8 > - =A0 =A0 =A0 andl =A0 =A0$4294967295, %edx > =A0 =A0 =A0 =A0shrq =A0 =A0$32, %rcx > - =A0 =A0 =A0 andl =A0 =A0$4294967295, %esi > + =A0 =A0 =A0 mov =A0 =A0 %esi, %esi Oh christ. What insane version of gcc is that? Can you please make a gcc bug-repor= t? Because a compiler that generates an instruction sequence like movq %rdi,%rsi andl $4294967295, %esi is just so fricking stupid that it's outright buggy. That's just crazy. It's demented. It's an "and" with all bits set. But yeah, I do think that in general using a cast to 32-bit instead of a mask to 32-bit is easier for the compiler. Although that still is a particularly stupid code sequence to use. Linus From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f44.google.com ([74.125.82.44]:56772 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757303Ab2DYBqg convert rfc822-to-8bit (ORCPT ); Tue, 24 Apr 2012 21:46:36 -0400 MIME-Version: 1.0 In-Reply-To: <1335304497.28150.243.camel@twins> References: <20120424161039.293018424@chello.nl> <20120424162224.526249106@chello.nl> <1335304497.28150.243.camel@twins> From: Linus Torvalds Date: Tue, 24 Apr 2012 18:46:14 -0700 Message-ID: Subject: Re: [RFC][PATCH 2/3] math128: Introduce {mult,add,cmp}_u128 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-arch-owner@vger.kernel.org List-ID: To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Andrew Morton , Juri Lelli , Ingo Molnar , Thomas Gleixner Message-ID: <20120425014614.51oNZNHCS-CCF3P0GDDDneYEmoYerEDSuQ8-IMif-C8@z> On Tue, Apr 24, 2012 at 2:54 PM, Peter Zijlstra wrote: > > that does generate slightly better code in that it avoids some masks on > 64bit: > > @@ -7,12 +7,11 @@ >  .LFB38: >        .cfi_startproc >        movq    %rdi, %r8 > -       movq    %rdi, %rdx >        movq    %rsi, %rcx > +       mov     %edi, %edx >        shrq    $32, %r8 > -       andl    $4294967295, %edx >        shrq    $32, %rcx > -       andl    $4294967295, %esi > +       mov     %esi, %esi Oh christ. What insane version of gcc is that? Can you please make a gcc bug-report? Because a compiler that generates an instruction sequence like movq %rdi,%rsi andl $4294967295, %esi is just so fricking stupid that it's outright buggy. That's just crazy. It's demented. It's an "and" with all bits set. But yeah, I do think that in general using a cast to 32-bit instead of a mask to 32-bit is easier for the compiler. Although that still is a particularly stupid code sequence to use. Linus