[llvm-commits] [PATCH] Add the transformation ~(~X >>s Y) --> (X >>s Y)
Jim Grosbach
grosbach at apple.com
Tue Jan 19 10:51:21 PST 2010
On Jan 19, 2010, at 8:36 AM, Edmund Grimley Evans wrote:
> Add this transformation in InstCombineAndOrXor.cpp:
>
> ~(~X >>s Y) --> (X >>s Y)
>
> It seems unlikely it could do any harm and it does have at least one
> use: together with other standard transformations it enables the
> following way of expressing an arithmetic shift right in portable C to
> be simplified into a single ASR operation:
>
> int asr(int a, int b)
> {
> return a < 0 ? -(-a - 1 >> b) - 1 : a >> b;
> }
Very nice! Thanks for the contribution.
More information about the llvm-commits
mailing list