[PATCH] D37158: [InstCombine][InstSimplify] Teach decomposeBitTestICmp to look through truncate instructions

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 25 11:49:41 PDT 2017


craig.topper created this revision.

This patch teaches decomposeBitTestICmp to look through truncate instructions on the input to the compare. If a truncate is found it will now return the pre-truncated Value and appropriately extend the APInt mask.

This allows some code to be removed from InstSimplify that was doing this functionality.

This allows InstCombine's bit test combining code to match a pre-truncate Value with the same Value appear with an 'and' on another icmp. Or it allows us to combine a truncate to i16 and a truncate to i8. This also required removing the type check from the beginning of getMaskedTypeForICmpPair, but I believe that's ok because we still have to find two values from the input to each icmp that are equal before we'll do any transformation. So the type check was really just serving as an early out.

There was one user of decomposeBitTestICmp that didn't want to look through truncates, so I've added a flag to prevent that behavior when necessary.


https://reviews.llvm.org/D37158

Files:
  include/llvm/Analysis/CmpInstAnalysis.h
  lib/Analysis/CmpInstAnalysis.cpp
  lib/Analysis/InstructionSimplify.cpp
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  lib/Transforms/InstCombine/InstCombineSelect.cpp
  test/Transforms/InstCombine/bit-checks.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37158.112722.patch
Type: text/x-patch
Size: 10059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170825/d79de16e/attachment.bin>


More information about the llvm-commits mailing list