[PATCH] D36498: [InstCombine] Teach foldSelectICmpAnd to recognize a (icmp slt trunc X, 0) and (icmp sgt trunc X, -1) as equivalent to an and with the sign bit of the truncated type

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 8 18:04:42 PDT 2017


craig.topper created this revision.

This is similar to what was already done in foldSelectICmpAndOr.  Ultimately I'd like to see if we can call foldSelectICmpAnd from foldSelectIntoOp if we detect a power of 2 constant. This would allow us to remove foldSelectICmpAndOr entirely.

As I'm writing this I wonder if we're also missing (icmp slt X, 0) and (icmp sgt X, -1) without any truncates.

The vector tests added should already work without this change since we don't turn compares with ands into truncate for vectors.


https://reviews.llvm.org/D36498

Files:
  lib/Transforms/InstCombine/InstCombineSelect.cpp
  test/Transforms/InstCombine/select-with-bitwise-ops.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36498.110315.patch
Type: text/x-patch
Size: 5256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170809/d690d237/attachment.bin>


More information about the llvm-commits mailing list