[PATCH] Added inst combine transforms for single bit tests from Chris's note (updated)

Dinesh Dwivedi dinesh.d at samsung.com
Thu May 15 02:01:33 PDT 2014

Hi bkramer, rafael,

I had to revert r208848 [http://reviews.llvm.org/D3717] due to assertion during builds :(

"include/llvm/ADT/APInt.h:960: bool llvm::APInt::operator==(const llvm::APInt&) const: Assertion `BitWidth == RHS.BitWidth && "Comparison requires equal bit widths"' failed."

I have updated patch to fix this issue. Now I am using APInt::isSameValue for comparison, which should be ok as these numbers are used in bitwise operations.

Is it ok now?

Summary from http://reviews.llvm.org/D3717
This patch adds transforms for

Single bit tests [http://nondot.org/sabre/LLVMNotes/InstCombine.txt]:
if ((x & C) == 0) x |= C	becomes	 x |= C
if ((x & C) != 0) x ^= C	becomes	 x &= ~C
if ((x & C) == 0) x ^= C	becomes	 x |= C
if ((x & C) != 0) x &= ~C	becomes	 x &= ~C
if ((x & C) == 0) x &= ~C	becomes	 nothing

Z3 Verifications code for above transform


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3777.9416.patch
Type: text/x-patch
Size: 4279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140515/7dbd5b3a/attachment.bin>

More information about the llvm-commits mailing list