From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============0487750786827238077==" MIME-Version: 1.0 From: Richard Henderson To: elfutils-devel@lists.fedorahosted.org Subject: Re: [PATCH 2/3] Simplify and inline get_uleb128 and get_sleb128 Date: Wed, 23 Apr 2014 08:27:11 -0700 Message-ID: <5357DBCF.70904@redhat.com> In-Reply-To: m2zjjcpcye.fsf@redhat.com --===============0487750786827238077== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 04/23/2014 03:17 AM, Petr Machata wrote: > Wouldn't something like this get us off the hook as well? > = > - (var) |=3D (typeof (var)) __s.i << ((nth) * 7); \ > + (var) |=3D (typeof (var)) \ > + (((uint64_t) (typeof (var)) __s.i) << ((nth) * 7)); \ > = > We are really only using the bitfield trick to avoid having to > sign-extend by hand, but we can shift unsigned without losing anything. It gets us off the hook, but might introduce a 64-bit shift where only a 32-bit shift was required. Sadly, (unsigned typeof(var)) doesn't work. ;-) But I gave the multiplication change a look, and the compiler is in fact optimizing the multiplication by a power of 2 back into a shift. r~ --===============0487750786827238077==--