From owner-svn-src-all@FreeBSD.ORG Thu Aug 19 23:40:39 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9CD3106566C; Thu, 19 Aug 2010 23:40:39 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id 3D1548FC1C; Thu, 19 Aug 2010 23:40:39 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:18ec:2038:19e5:d1cb] (unknown [IPv6:2001:7b8:3a7:0:18ec:2038:19e5:d1cb]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 561EC5C59; Fri, 20 Aug 2010 01:40:38 +0200 (CEST) Message-ID: <4C6DC0F8.9040001@andric.com> Date: Fri, 20 Aug 2010 01:40:40 +0200 From: Dimitry Andric User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.9pre) Gecko/20100814 Lanikai/3.1.3pre MIME-Version: 1.0 To: Bruce Evans References: <201008191259.o7JCxv3i004613@svn.freebsd.org> <20100820075236.L18914@delplex.bde.org> In-Reply-To: <20100820075236.L18914@delplex.bde.org> Content-Type: multipart/mixed; boundary="------------040908050209090200010707" Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Rui Paulo Subject: Re: svn commit: r211505 - head/contrib/gcc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Aug 2010 23:40:39 -0000 This is a multi-part message in MIME format. --------------040908050209090200010707 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 2010-08-20 00:20, Bruce Evans wrote: > 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... But will the casts not potentially hide problems, if you pass the wrong types to those macros? Maybe it is better if the compiler complains that some argument is of an incompatible type, than just forcing it to cast? >> 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. Yes, clang complains precisely about that: gnu/lib/libgcc/../../../contrib/gcc/libgcc2.c:536:22: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions DWunion w = {.ll = __umulsidi3 (uu.s.low, vv.s.low)}; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from gnu/lib/libgcc/../../../contrib/gcc/libgcc2.c:65: In file included from gnu/lib/libgcc/../../../contrib/gcc/libgcc2.h:435: gnu/lib/libgcc/../../../contrib/gcc/longlong.h:1293:5: note: instantiated from: umul_ppmm (__w.s.high, __w.s.low, u, v); \ ^ It turns out that only removing the casts for these specific lvalues is indeed enough to make clang happy. Attached patch reverts all other changes, if that is to be preferred. >> 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. contrib/gcc/longlong.h is only used in contrib/gcc/libgcc2.h, and in contrib/gcc/config/soft-fp/soft-fp.h. On i386, soft-fp is not used, and libgcc2.h is only used in contrib/gcc/libgcc2.c, so libgcc is the only consumer, as far as I can see. --------------040908050209090200010707 Content-Type: text/plain; name="longlong-minimal.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="longlong-minimal.diff" diff --git a/contrib/gcc/longlong.h b/contrib/gcc/longlong.h index 8805d91..a789d16 100644 --- a/contrib/gcc/longlong.h +++ b/contrib/gcc/longlong.h @@ -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" (sh), \ - "=&r" (sl) \ - : "%0" (ah), \ - "g" (bh), \ - "%1" (al), \ - "g" (bl)) + : "=r" ((USItype) (sh)), \ + "=&r" ((USItype) (sl)) \ + : "%0" ((USItype) (ah)), \ + "g" ((USItype) (bh)), \ + "%1" ((USItype) (al)), \ + "g" ((USItype) (bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl %5,%1\n\tsbbl %3,%0" \ : "=r" (sh), \ "=&r" (sl) \ - : "0" (ah), \ - "g" (bh), \ - "1" (al), \ - "g" (bl)) + : "0" ((USItype) (ah)), \ + "g" ((USItype) (bh)), \ + "1" ((USItype) (al)), \ + "g" ((USItype) (bl))) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mull %3" \ : "=a" (w0), \ "=d" (w1) \ - : "%0" (u), \ - "rm" (v)) + : "%0" ((USItype) (u)), \ + "rm" ((USItype) (v))) #define udiv_qrnnd(q, r, n1, n0, dv) \ __asm__ ("divl %4" \ : "=a" (q), \ "=d" (r) \ - : "0" (n0), \ - "1" (n1), \ - "rm" (dv)) + : "0" ((USItype) (n0)), \ + "1" ((USItype) (n1)), \ + "rm" ((USItype) (dv))) #define count_leading_zeros(count, x) \ do { \ USItype __cbtmp; \ __asm__ ("bsrl %1,%0" \ - : "=r" (__cbtmp) : "rm" (x)); \ + : "=r" (__cbtmp) : "rm" ((USItype) (x))); \ (count) = __cbtmp ^ 31; \ } while (0) #define count_trailing_zeros(count, x) \ --------------040908050209090200010707--