[llvm-commits] [PATCH] Add the transformation ~(~X >>s Y) --> (X >>s Y)

Edmund Grimley Evans Edmund.Grimley-Evans at arm.com
Tue Jan 19 08:36:35 PST 2010


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;
}

-- 
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: asr.patch
Type: text/x-patch
Size: 2610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100119/e8cad18d/attachment.bin>


More information about the llvm-commits mailing list