[PATCH] D22537: [InstSimplify] recognize trunc + icmp sgt/slt variants of select simplifications (PR28466)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 08:29:57 PDT 2016


spatel added a comment.

In https://reviews.llvm.org/D22537#489198, @eli.friedman wrote:

> It looks like there are other places that look for bit-tests which are affected... see https://github.com/llvm-mirror/llvm/blob/dba9c3285e87768e80da6ca60f73b8913392dd98/lib/Transforms/InstCombine/InstCombineSelect.cpp#L579 , https://github.com/llvm-mirror/llvm/blob/65165b21da2aaed908f7bde1b8a16e7a8fe0c955/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp#L597 .  Maybe we want a separate utility function to condense this functionality, so we don't end up with so many versions of it?


Yikes - I didn't realize it was so blatantly copied in other places. That is pretty shameful. Let me see if there's a quick fix, otherwise I'll mark it as a FIXME for this patch.


================
Comment at: lib/Analysis/InstructionSimplify.cpp:3411
@@ +3410,3 @@
+/// eq/ne.
+static Value *simplifySelectWithFakeICmpEq(Value *CmpLHS, Value *TrueVal,
+                                           Value *FalseVal, bool TrueWhenUnset,
----------------
eli.friedman wrote:
> Do we want to look through the truncate in something like "(trunc X) & C == C2 ? X : Y"?
Is this the pattern in the last 4 tests of this patch, or something more general?

================
Comment at: lib/Analysis/InstructionSimplify.cpp:3414
@@ +3413,3 @@
+                                           const DataLayout &DL) {
+  unsigned BitWidth = DL.getTypeSizeInBits(TrueVal->getType());
+  APInt MinSignedValue;
----------------
eli.friedman wrote:
> getScalarSizeInBits?  (This could be a vector select.)
Yes - this was copied from the existing code. I was going to enable vectors as a follow-up to this patch.


https://reviews.llvm.org/D22537





More information about the llvm-commits mailing list