From owner-svn-src-head@FreeBSD.ORG Thu Aug 19 22:21:02 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF3BE1065673; Thu, 19 Aug 2010 22:21:02 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail06.syd.optusnet.com.au (mail06.syd.optusnet.com.au [211.29.132.187]) by mx1.freebsd.org (Postfix) with ESMTP id 045A18FC16; Thu, 19 Aug 2010 22:21:01 +0000 (UTC) Received: from c211-30-198-138.carlnfd1.nsw.optusnet.com.au (c211-30-198-138.carlnfd1.nsw.optusnet.com.au [211.30.198.138]) by mail06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o7JMKwub011061 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 20 Aug 2010 08:20:59 +1000 Date: Fri, 20 Aug 2010 08:20:57 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Rui Paulo In-Reply-To: <201008191259.o7JCxv3i004613@svn.freebsd.org> Message-ID: <20100820075236.L18914@delplex.bde.org> References: <201008191259.o7JCxv3i004613@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r211505 - head/contrib/gcc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Aug 2010 22:21:02 -0000 On Thu, 19 Aug 2010, Rui Paulo wrote: > Log: > Remove unneeded casts in inline assembly in contrib/gcc/longlong.h, These seem to be needed, and some of them valid. Any lvalue arg that can be put in a register can be cast to USItype (unsigned int) on i386. The args are macro args, so they may have any integer type no larger than USItype originally, and they must be cast to USItype for the asms to work if the args are smaller than USItype... > which are apparently "heinous" GNU extensions, so clang can > compile this without using the -fheinous-gnu-extensions option. But when the args are lvalues, casting them is invalid. This is apparently the heinous extension depended on. > > Results in *no* binary change, neither with clang, nor with gcc. This cannot be tested by compiling a few binaries, since the few binaries might not include enough examples to give test coverage of cases with args smaller than USItype. Perhaps the macros are only used for building libgcc, but this is unclear. > Modified: head/contrib/gcc/longlong.h > ============================================================================== > --- head/contrib/gcc/longlong.h Thu Aug 19 12:52:49 2010 (r211504) > +++ head/contrib/gcc/longlong.h Thu Aug 19 12:59:57 2010 (r211505) > @@ -314,38 +314,38 @@ UDItype __umulsidi3 (USItype, USItype); > #if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32 > #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ > __asm__ ("addl %5,%1\n\tadcl %3,%0" \ > - : "=r" ((USItype) (sh)), \ > - "=&r" ((USItype) (sl)) \ I can only see a problem with casting lvalues (2 here). The corrected version might use "USItype _sh = (sh); ... (sh) = _sh;", etc. > - : "%0" ((USItype) (ah)), \ > - "g" ((USItype) (bh)), \ > - "%1" ((USItype) (al)), \ > - "g" ((USItype) (bl))) > + : "=r" (sh), \ > + "=&r" (sl) \ > + : "%0" (ah), \ > + "g" (bh), \ > + "%1" (al), \ > + "g" (bl)) > #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ > __asm__ ("subl %5,%1\n\tsbbl %3,%0" \ > - : "=r" ((USItype) (sh)), \ > - "=&r" ((USItype) (sl)) \ Most of the asms have 2 problematic lvalues. > - : "0" ((USItype) (ah)), \ Casting this rvalue shouldn't cause problems, but it is unclear if "0" can be the same arg as "=r" if they are cast differently. > - "g" ((USItype) (bh)), \ > - "1" ((USItype) (al)), \ > - "g" ((USItype) (bl))) > + : "=r" (sh), \ > + "=&r" (sl) \ > + : "0" (ah), \ > + "g" (bh), \ > + "1" (al), \ > + "g" (bl)) > #define umul_ppmm(w1, w0, u, v) \ > __asm__ ("mull %3" \ > - : "=a" ((USItype) (w0)), \ > - "=d" ((USItype) (w1)) \ > - : "%0" ((USItype) (u)), \ > - "rm" ((USItype) (v))) > + : "=a" (w0), \ > + "=d" (w1) \ > + : "%0" (u), \ > + "rm" (v)) > #define udiv_qrnnd(q, r, n1, n0, dv) \ > __asm__ ("divl %4" \ > - : "=a" ((USItype) (q)), \ > - "=d" ((USItype) (r)) \ > - : "0" ((USItype) (n0)), \ > - "1" ((USItype) (n1)), \ > - "rm" ((USItype) (dv))) > + : "=a" (q), \ > + "=d" (r) \ > + : "0" (n0), \ > + "1" (n1), \ > + "rm" (dv)) > #define count_leading_zeros(count, x) \ > do { \ > USItype __cbtmp; \ > __asm__ ("bsrl %1,%0" \ > - : "=r" (__cbtmp) : "rm" ((USItype) (x))); \ > + : "=r" (__cbtmp) : "rm" (x)); \ Here the lvalue is already a temporary variable, and there should be no problem casting the rvalue. > (count) = __cbtmp ^ 31; \ > } while (0) > #define count_trailing_zeros(count, x) \ > Here the lvalue already wasn't casted, and the rvalue is still casted. Bruce