[PATCH] Enhance urem to bitwise-and optimization

David Majnemer david.majnemer at gmail.com
Wed May 8 23:32:54 PDT 2013


On Wed, May 8, 2013 at 8:54 PM, Rafael EspĂ­ndola <rafael.espindola at gmail.com
> wrote:

> >>
> >> Is the select case really redundant now?
> >
> > Yes, llvm::isKnownToBeAPowerOfTwo has support for select instructions.
> The
> > function 'test4' in rem.ll provides verification that we still handle
> select
> > instructions.
>
> OK. We will now convert
>
> urem X, (select Cond, 2^C1, 2^C2)
>
> to
>
> X and ((select Cond, 2^C1, 2^C2) - 1)
>
> Instead of creating the two ands. I guess that is fine.


InstCombiner::visitSelectInst will actually turn

(select Cond, X and 2^C1 - 1, 2^C2- 1)

to

X and (select Cond 2^C1 - 1, 2^C2- 1) so it works out the same in the end
for that case.

Having the
> test uses filecehck should make this change explicit to anyone reading
> the patch.
>

An updated patch is attached.


>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130508/cadffc7c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: urem-to-and.diff
Type: application/octet-stream
Size: 4966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130508/cadffc7c/attachment.obj>


More information about the llvm-commits mailing list