[llvm-commits] [PATCH] Add the transformation ~(~X >>s Y) --> (X >>s Y)
Chris Lattner
clattner at apple.com
Tue Jan 19 10:17:24 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;
> }
Looks great, I tweaked the testcases a bit and committed it as r93884.
The tweaks are to add the minimal testcase to an existing .ll file
(xor2.ll) and make the "whole idiom recognizer" testcase into a new
idioms.ll file, which only tests the instcombine part of the xform.
Thanks for the patch!
-Chris
More information about the llvm-commits
mailing list