[PATCH] D50775: [InstCombine] Fix IC trying to create a xor of pointer types

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 15 10:47:10 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL339796: [InstCombine] Fix IC trying to create a xor of pointer types. (authored by aemerson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50775?vs=160845&id=160850#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50775

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  llvm/trunk/test/Transforms/InstCombine/xor-icmps.ll


Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2487,7 +2487,8 @@
   Value *LHS0 = LHS->getOperand(0), *LHS1 = LHS->getOperand(1);
   Value *RHS0 = RHS->getOperand(0), *RHS1 = RHS->getOperand(1);
   if ((LHS->hasOneUse() || RHS->hasOneUse()) &&
-      LHS0->getType() == RHS0->getType()) {
+      LHS0->getType() == RHS0->getType() &&
+      LHS0->getType()->isIntOrIntVectorTy()) {
     // (X > -1) ^ (Y > -1) --> (X ^ Y) < 0
     // (X <  0) ^ (Y <  0) --> (X ^ Y) < 0
     if ((PredL == CmpInst::ICMP_SGT && match(LHS1, m_AllOnes()) &&
Index: llvm/trunk/test/Transforms/InstCombine/xor-icmps.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/xor-icmps.ll
+++ llvm/trunk/test/Transforms/InstCombine/xor-icmps.ll
@@ -158,3 +158,16 @@
   ret i1 %E
 }
 
+define i1 @xor_icmp_ptr(i8* %c, i8* %d) {
+; CHECK-LABEL: @xor_icmp_ptr(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i8* [[C:%.*]], null
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp slt i8* [[D:%.*]], null
+; CHECK-NEXT:    [[XOR:%.*]] = xor i1 [[CMP]], [[CMP1]]
+; CHECK-NEXT:    ret i1 [[XOR]]
+;
+  %cmp = icmp slt i8* %c, null
+  %cmp1 = icmp slt i8* %d, null
+  %xor = xor i1 %cmp, %cmp1
+  ret i1 %xor
+}
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50775.160850.patch
Type: text/x-patch
Size: 1446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180815/256ce161/attachment.bin>


More information about the llvm-commits mailing list