[PATCH] D32665: [InstCombine] don't use DeMorgan's Law on integer constants

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 17:13:46 PDT 2017


Hi Chandler,

You're listed as an admin of Phab...and yet your email address(es) are
shown as not verified, so I don't think it sent you mail about this patch!

On Fri, Apr 28, 2017 at 5:55 PM, Sanjay Patel via Phabricator <
reviews at reviews.llvm.org> wrote:

> spatel created this revision.
> Herald added subscribers: mcrosier, rengolin, aemerson.
>
> This is the fold that causes the infinite loop in BoringSSL (
> https://github.com/google/boringssl/blob/master/crypto/cipher/e_rc2.c)
> when we fix instcombine demanded bits to prefer 'not' ops as in
> https://reviews.llvm.org/D32255.
>
> There are 2 or 3 problems with dyn_castNotVal, and I don't think we can
> reinstate https://reviews.llvm.org/D32255 until dyn_castNotVal is
> completely eliminated:
>
> 1. As shown here, it transforms 'not' into random xor. This transform is
> harmful to SCEV and codegen because 'not' can often be folded while random
> xor cannot.
> 2. It does not transform vector constants. This is actually a good thing,
> but if you don't believe the above argument, then we shouldn't have
> excluded vectors.
> 3. It tries to avoid transforming not(not(X)). That's nice, but it doesn't
> match the greedy nature of instcombine. If we DeMorganize a pattern that
> has an extra 'not' in it:
>
> ~(~(~X) & Y) --> (~X | ~Y)
> That's just another case of DeMorgan, so we should trust that we'll get
> that too:
> (~X | ~ Y) --> ~(X & Y)
>
>
> https://reviews.llvm.org/D32665
>
> Files:
>   lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
>   test/Transforms/InstCombine/and-or.ll
>   test/Transforms/InstCombine/assume2.ll
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170428/e42ac4c1/attachment.html>


More information about the llvm-commits mailing list