Ping 2: [PATCH] DAGCombiner: Recognise rotates by X+C

Richard Sandiford rsandifo at linux.vnet.ibm.com
Mon Dec 23 07:24:12 PST 2013


Kay Tiong Khoo <kkhoo at perfwizard.com> writes:
> Hi Richard,
>
> Could this patch be enhanced to recognize this case too:
> http://llvm.org/bugs/show_bug.cgi?id=17332#c12
>
> Maybe it already does? Sorry, I can't test it myself at the moment.

Hi, thanks for the pointer.  The patch didn't handle that case but I agree
it'd be a good thing to add.

Here's a version that does both.  I've split it into three patches:

(1) is just a refactoring exercise.  It's easier to make changes to this
    code if there's only one copy of it.  No behavioural change intended.

(2) is my original patch adjusted for (1).  E.g. we now recognise:
       (or (shl X, (add Y, 10)), (shr X, (sub 22, Y)))
    as a rotate by Y + 10.

(3) also handles cases where the shift amount is ANDed.  E.g. we now
    recognise:
       (or (shl X, Y), (shr X, (and (sub 0, Y), 31)))
       (or (shl X, Y), (shr X, (and (sub 32, Y), 31)))
    as rotates by Y.  We can also handle redundant ANDs for (2) too:
       (or (shl X, (add Y, 10)), (shr X, (and (sub 22, Y), 31)))

OK to commit?

Thanks,
Richard


-------------- next part --------------
A non-text attachment was scrubbed...
Name: rotate-1.diff
Type: text/x-patch
Size: 7555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131223/23e4930c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rotate-2.diff
Type: text/x-patch
Size: 4440 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131223/23e4930c/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rotate-3.diff
Type: text/x-patch
Size: 4044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131223/23e4930c/attachment-0002.bin>


More information about the llvm-commits mailing list