summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmara Emerson <aemerson@apple.com>2018-08-15 17:46:22 +0000
committerAmara Emerson <aemerson@apple.com>2018-08-15 17:46:22 +0000
commit070ac768ff4ddeb372ec5d91d570ddc545fceede (patch)
treee81fde4c393ca7c8b655856c8a5de708155a96b4
parentcc2e8ccc6fced5931a31f2ba90a9d1c22dc80cde (diff)
downloadbcm5719-llvm-070ac768ff4ddeb372ec5d91d570ddc545fceede.tar.gz
bcm5719-llvm-070ac768ff4ddeb372ec5d91d570ddc545fceede.zip
[InstCombine] Fix IC trying to create a xor of pointer types.
rdar://42473741 Differential Revision: https://reviews.llvm.org/D50775 llvm-svn: 339796
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp3
-rw-r--r--llvm/test/Transforms/InstCombine/xor-icmps.ll13
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 36180c00348..a2dea10c565 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2487,7 +2487,8 @@ Value *InstCombiner::foldXorOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
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()) &&
diff --git a/llvm/test/Transforms/InstCombine/xor-icmps.ll b/llvm/test/Transforms/InstCombine/xor-icmps.ll
index e19a061c7cc..7f0a8d8cd2a 100644
--- a/llvm/test/Transforms/InstCombine/xor-icmps.ll
+++ b/llvm/test/Transforms/InstCombine/xor-icmps.ll
@@ -158,3 +158,16 @@ define i1 @test14(i8 %A, i8 %B) {
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
+}
+
OpenPOWER on IntegriCloud