This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
- From: "Tulio Magno Quites Machado Filho" <tuliom at linux dot vnet dot ibm dot com>
- To: "Gabriel F. T. Gomes" <gftg at linux dot vnet dot ibm dot com>
- Cc: Joseph Myers <joseph at codesourcery dot com>, <timshen at google dot com>, <libc-alpha at sourceware dot org>
- Cc:
- Date: Tue, 08 Mar 2016 15:36:46 -0300
- Subject: Re: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
- Authentication-results: sourceware.org; auth=none
- References: <87egdbumu6 dot fsf at totoro dot br dot ibm dot com> <1453901144-3662-1-git-send-email-gftg at linux dot vnet dot ibm dot com> <alpine dot DEB dot 2 dot 10 dot 1601271715020 dot 6975 at digraph dot polyomino dot org dot uk> <20160129161445 dot 526fbb52 at keller>
"Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com> writes:
> Subject: [PATCH] powerpc: Remove uses of operand modifier (%s) in inline asm
>
> The operand modifier %s on powerpc is an undocumented internal implementation
> detail of GCC. Besides that, the GCC community wants to remove it. This patch
> rewrites the expressions that use this modifier with logically equivalent
> expressions that don't require it.
>
> Explanation for the substitution:
>
> The %s modifier takes an immediate operand and prints 32 less such immediate.
> Thus, in the previous code, the expression resulted in:
>
> 32 - __builtin_ffs(e)
>
> where e was guaranteed to have exactly a single bit set, by the following
> expressions:
>
> (e & (e-1) == 0) : e has at most one bit set.
> (e != 0) : e is not zero, thus it has at least one bit set.
>
> Since we guarantee that there is exactly only one bit set, the following
> statement is true:
>
> 32 - __builtin_ffs(e) == __builtin_clz(e)
>
> Thus, we can replace __builtin_ffs with __builtin_clz and remove the %s operand
> modifier.
Pushed as 183a34d.
Thanks!
--
Tulio Magno