From 9b1b2de348e391632bd1c8d4460ff03926269f2c Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 6 Dec 2016 19:05:46 +0000 Subject: [PATCH] [InstSimplify] add folds for and-of-icmps with same operands All of these (and a few more) are already handled by InstCombine, but we shouldn't have to wait until then to simplify these because they're cheap to deal with here in InstSimplify. This is the 'and' sibling of the earlier 'or' patch: https://reviews.llvm.org/rL288833 llvm-svn: 288841 --- llvm/lib/Analysis/InstructionSimplify.cpp | 33 +++ .../Transforms/InstSimplify/and-icmps-same-ops.ll | 255 +++++---------------- 2 files changed, 91 insertions(+), 197 deletions(-) diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 26d1635..cc4a6ba 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -1518,10 +1518,43 @@ static Value *simplifyUnsignedRangeCheck(ICmpInst *ZeroICmp, return nullptr; } +/// Commuted variants are assumed to be handled by calling this function again +/// with the parameters swapped. +static Value *simplifyAndOfICmpsWithSameOperands(ICmpInst *Op0, ICmpInst *Op1) { + ICmpInst::Predicate Pred0, Pred1; + Value *A ,*B; + match(Op0, m_ICmp(Pred0, m_Value(A), m_Value(B))); + if (match(Op1, m_ICmp(Pred1, m_Specific(B), m_Specific(A)))) + Op1->swapOperands(); + + if (!match(Op1, m_ICmp(Pred1, m_Specific(A), m_Specific(B)))) + return nullptr; + + // We have (icmp Pred0, A, B) & (icmp Pred1, A, B). + // If Op1 is always implied true by Op0, then Op0 is a subset of Op1, and we + // can eliminate Op1 from this 'and'. + if (ICmpInst::isImpliedTrueByMatchingCmp(Pred0, Pred1)) + return Op0; + + // Check for any combination of predicates that are guaranteed to be disjoint. + if ((Pred0 == ICmpInst::getInversePredicate(Pred1)) || + (Pred0 == ICmpInst::ICMP_EQ && ICmpInst::isFalseWhenEqual(Pred1)) || + (Pred0 == ICmpInst::ICMP_SLT && Pred1 == ICmpInst::ICMP_SGT) || + (Pred0 == ICmpInst::ICMP_ULT && Pred1 == ICmpInst::ICMP_UGT)) + return getFalse(Op0->getType()); + + return nullptr; +} + +/// Commuted variants are assumed to be handled by calling this function again +/// with the parameters swapped. static Value *SimplifyAndOfICmps(ICmpInst *Op0, ICmpInst *Op1) { if (Value *X = simplifyUnsignedRangeCheck(Op0, Op1, /*IsAnd=*/true)) return X; + if (Value *X = simplifyAndOfICmpsWithSameOperands(Op0, Op1)) + return X; + // Look for this pattern: (icmp V, C0) & (icmp V, C1)). Type *ITy = Op0->getType(); ICmpInst::Predicate Pred0, Pred1; diff --git a/llvm/test/Transforms/InstSimplify/and-icmps-same-ops.ll b/llvm/test/Transforms/InstSimplify/and-icmps-same-ops.ll index 6e7da27..8a665c3 100644 --- a/llvm/test/Transforms/InstSimplify/and-icmps-same-ops.ll +++ b/llvm/test/Transforms/InstSimplify/and-icmps-same-ops.ll @@ -7,9 +7,7 @@ define i1 @eq_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_eq( ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -19,10 +17,7 @@ define i1 @eq_eq(i8 %a, i8 %b) { define i1 @eq_ne(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_ne( -; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp ne i8 %a, %b @@ -33,9 +28,7 @@ define i1 @eq_ne(i8 %a, i8 %b) { define i1 @eq_sge(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_sge( ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp sge i8 %a, %b @@ -45,10 +38,7 @@ define i1 @eq_sge(i8 %a, i8 %b) { define i1 @eq_sgt(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_sgt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp sgt i8 %a, %b @@ -59,9 +49,7 @@ define i1 @eq_sgt(i8 %a, i8 %b) { define i1 @eq_sle(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_sle( ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp sle i8 %a, %b @@ -71,10 +59,7 @@ define i1 @eq_sle(i8 %a, i8 %b) { define i1 @eq_slt(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_slt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp slt i8 %a, %b @@ -85,9 +70,7 @@ define i1 @eq_slt(i8 %a, i8 %b) { define i1 @eq_uge(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_uge( ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp uge i8 %a, %b @@ -97,10 +80,7 @@ define i1 @eq_uge(i8 %a, i8 %b) { define i1 @eq_ugt(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_ugt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp ugt i8 %a, %b @@ -111,9 +91,7 @@ define i1 @eq_ugt(i8 %a, i8 %b) { define i1 @eq_ule(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_ule( ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ule i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp ule i8 %a, %b @@ -123,10 +101,7 @@ define i1 @eq_ule(i8 %a, i8 %b) { define i1 @eq_ult(i8 %a, i8 %b) { ; CHECK-LABEL: @eq_ult( -; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp eq i8 %a, %b %cmp2 = icmp ult i8 %a, %b @@ -138,10 +113,7 @@ define i1 @eq_ult(i8 %a, i8 %b) { define i1 @ne_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @ne_eq( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp ne i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -152,9 +124,7 @@ define i1 @ne_eq(i8 %a, i8 %b) { define i1 @ne_ne(i8 %a, i8 %b) { ; CHECK-LABEL: @ne_ne( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp ne i8 %a, %b %cmp2 = icmp ne i8 %a, %b @@ -177,10 +147,8 @@ define i1 @ne_sge(i8 %a, i8 %b) { define i1 @ne_sgt(i8 %a, i8 %b) { ; CHECK-LABEL: @ne_sgt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp ne i8 %a, %b %cmp2 = icmp sgt i8 %a, %b @@ -203,10 +171,8 @@ define i1 @ne_sle(i8 %a, i8 %b) { define i1 @ne_slt(i8 %a, i8 %b) { ; CHECK-LABEL: @ne_slt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp ne i8 %a, %b %cmp2 = icmp slt i8 %a, %b @@ -229,10 +195,8 @@ define i1 @ne_uge(i8 %a, i8 %b) { define i1 @ne_ugt(i8 %a, i8 %b) { ; CHECK-LABEL: @ne_ugt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp ne i8 %a, %b %cmp2 = icmp ugt i8 %a, %b @@ -255,10 +219,8 @@ define i1 @ne_ule(i8 %a, i8 %b) { define i1 @ne_ult(i8 %a, i8 %b) { ; CHECK-LABEL: @ne_ult( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp ne i8 %a, %b %cmp2 = icmp ult i8 %a, %b @@ -270,10 +232,8 @@ define i1 @ne_ult(i8 %a, i8 %b) { define i1 @sge_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @sge_eq( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp sge i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -297,9 +257,7 @@ define i1 @sge_ne(i8 %a, i8 %b) { define i1 @sge_sge(i8 %a, i8 %b) { ; CHECK-LABEL: @sge_sge( ; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp sge i8 %a, %b %cmp2 = icmp sge i8 %a, %b @@ -309,10 +267,8 @@ define i1 @sge_sge(i8 %a, i8 %b) { define i1 @sge_sgt(i8 %a, i8 %b) { ; CHECK-LABEL: @sge_sgt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp sge i8 %a, %b %cmp2 = icmp sgt i8 %a, %b @@ -335,10 +291,7 @@ define i1 @sge_sle(i8 %a, i8 %b) { define i1 @sge_slt(i8 %a, i8 %b) { ; CHECK-LABEL: @sge_slt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp sge i8 %a, %b %cmp2 = icmp slt i8 %a, %b @@ -402,10 +355,7 @@ define i1 @sge_ult(i8 %a, i8 %b) { define i1 @sgt_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @sgt_eq( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp sgt i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -416,9 +366,7 @@ define i1 @sgt_eq(i8 %a, i8 %b) { define i1 @sgt_ne(i8 %a, i8 %b) { ; CHECK-LABEL: @sgt_ne( ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp sgt i8 %a, %b %cmp2 = icmp ne i8 %a, %b @@ -429,9 +377,7 @@ define i1 @sgt_ne(i8 %a, i8 %b) { define i1 @sgt_sge(i8 %a, i8 %b) { ; CHECK-LABEL: @sgt_sge( ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp sgt i8 %a, %b %cmp2 = icmp sge i8 %a, %b @@ -442,9 +388,7 @@ define i1 @sgt_sge(i8 %a, i8 %b) { define i1 @sgt_sgt(i8 %a, i8 %b) { ; CHECK-LABEL: @sgt_sgt( ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp sgt i8 %a, %b %cmp2 = icmp sgt i8 %a, %b @@ -454,10 +398,7 @@ define i1 @sgt_sgt(i8 %a, i8 %b) { define i1 @sgt_sle(i8 %a, i8 %b) { ; CHECK-LABEL: @sgt_sle( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp sgt i8 %a, %b %cmp2 = icmp sle i8 %a, %b @@ -467,10 +408,7 @@ define i1 @sgt_sle(i8 %a, i8 %b) { define i1 @sgt_slt(i8 %a, i8 %b) { ; CHECK-LABEL: @sgt_slt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp sgt i8 %a, %b %cmp2 = icmp slt i8 %a, %b @@ -534,10 +472,8 @@ define i1 @sgt_ult(i8 %a, i8 %b) { define i1 @sle_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @sle_eq( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp sle i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -573,10 +509,7 @@ define i1 @sle_sge(i8 %a, i8 %b) { define i1 @sle_sgt(i8 %a, i8 %b) { ; CHECK-LABEL: @sle_sgt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp sle i8 %a, %b %cmp2 = icmp sgt i8 %a, %b @@ -587,9 +520,7 @@ define i1 @sle_sgt(i8 %a, i8 %b) { define i1 @sle_sle(i8 %a, i8 %b) { ; CHECK-LABEL: @sle_sle( ; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp sle i8 %a, %b %cmp2 = icmp sle i8 %a, %b @@ -599,10 +530,8 @@ define i1 @sle_sle(i8 %a, i8 %b) { define i1 @sle_slt(i8 %a, i8 %b) { ; CHECK-LABEL: @sle_slt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp sle i8 %a, %b %cmp2 = icmp slt i8 %a, %b @@ -666,10 +595,7 @@ define i1 @sle_ult(i8 %a, i8 %b) { define i1 @slt_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @slt_eq( -; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp slt i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -680,9 +606,7 @@ define i1 @slt_eq(i8 %a, i8 %b) { define i1 @slt_ne(i8 %a, i8 %b) { ; CHECK-LABEL: @slt_ne( ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp slt i8 %a, %b %cmp2 = icmp ne i8 %a, %b @@ -692,10 +616,7 @@ define i1 @slt_ne(i8 %a, i8 %b) { define i1 @slt_sge(i8 %a, i8 %b) { ; CHECK-LABEL: @slt_sge( -; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp slt i8 %a, %b %cmp2 = icmp sge i8 %a, %b @@ -705,10 +626,7 @@ define i1 @slt_sge(i8 %a, i8 %b) { define i1 @slt_sgt(i8 %a, i8 %b) { ; CHECK-LABEL: @slt_sgt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp slt i8 %a, %b %cmp2 = icmp sgt i8 %a, %b @@ -719,9 +637,7 @@ define i1 @slt_sgt(i8 %a, i8 %b) { define i1 @slt_sle(i8 %a, i8 %b) { ; CHECK-LABEL: @slt_sle( ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp slt i8 %a, %b %cmp2 = icmp sle i8 %a, %b @@ -732,9 +648,7 @@ define i1 @slt_sle(i8 %a, i8 %b) { define i1 @slt_slt(i8 %a, i8 %b) { ; CHECK-LABEL: @slt_slt( ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp slt i8 %a, %b %cmp2 = icmp slt i8 %a, %b @@ -798,10 +712,8 @@ define i1 @slt_ult(i8 %a, i8 %b) { define i1 @uge_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @uge_eq( -; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp uge i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -877,9 +789,7 @@ define i1 @uge_slt(i8 %a, i8 %b) { define i1 @uge_uge(i8 %a, i8 %b) { ; CHECK-LABEL: @uge_uge( ; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp uge i8 %a, %b %cmp2 = icmp uge i8 %a, %b @@ -889,10 +799,8 @@ define i1 @uge_uge(i8 %a, i8 %b) { define i1 @uge_ugt(i8 %a, i8 %b) { ; CHECK-LABEL: @uge_ugt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp uge i8 %a, %b %cmp2 = icmp ugt i8 %a, %b @@ -915,10 +823,7 @@ define i1 @uge_ule(i8 %a, i8 %b) { define i1 @uge_ult(i8 %a, i8 %b) { ; CHECK-LABEL: @uge_ult( -; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp uge i8 %a, %b %cmp2 = icmp ult i8 %a, %b @@ -930,10 +835,7 @@ define i1 @uge_ult(i8 %a, i8 %b) { define i1 @ugt_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @ugt_eq( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp ugt i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -944,9 +846,7 @@ define i1 @ugt_eq(i8 %a, i8 %b) { define i1 @ugt_ne(i8 %a, i8 %b) { ; CHECK-LABEL: @ugt_ne( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp ugt i8 %a, %b %cmp2 = icmp ne i8 %a, %b @@ -1009,9 +909,7 @@ define i1 @ugt_slt(i8 %a, i8 %b) { define i1 @ugt_uge(i8 %a, i8 %b) { ; CHECK-LABEL: @ugt_uge( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp ugt i8 %a, %b %cmp2 = icmp uge i8 %a, %b @@ -1022,9 +920,7 @@ define i1 @ugt_uge(i8 %a, i8 %b) { define i1 @ugt_ugt(i8 %a, i8 %b) { ; CHECK-LABEL: @ugt_ugt( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp ugt i8 %a, %b %cmp2 = icmp ugt i8 %a, %b @@ -1034,10 +930,7 @@ define i1 @ugt_ugt(i8 %a, i8 %b) { define i1 @ugt_ule(i8 %a, i8 %b) { ; CHECK-LABEL: @ugt_ule( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ule i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp ugt i8 %a, %b %cmp2 = icmp ule i8 %a, %b @@ -1047,10 +940,7 @@ define i1 @ugt_ule(i8 %a, i8 %b) { define i1 @ugt_ult(i8 %a, i8 %b) { ; CHECK-LABEL: @ugt_ult( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp ugt i8 %a, %b %cmp2 = icmp ult i8 %a, %b @@ -1062,10 +952,8 @@ define i1 @ugt_ult(i8 %a, i8 %b) { define i1 @ule_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @ule_eq( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp ule i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -1153,10 +1041,7 @@ define i1 @ule_uge(i8 %a, i8 %b) { define i1 @ule_ugt(i8 %a, i8 %b) { ; CHECK-LABEL: @ule_ugt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp ule i8 %a, %b %cmp2 = icmp ugt i8 %a, %b @@ -1167,9 +1052,7 @@ define i1 @ule_ugt(i8 %a, i8 %b) { define i1 @ule_ule(i8 %a, i8 %b) { ; CHECK-LABEL: @ule_ule( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ule i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp ule i8 %a, %b %cmp2 = icmp ule i8 %a, %b @@ -1179,10 +1062,8 @@ define i1 @ule_ule(i8 %a, i8 %b) { define i1 @ule_ult(i8 %a, i8 %b) { ; CHECK-LABEL: @ule_ult( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i8 %a, %b ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP2]] ; %cmp1 = icmp ule i8 %a, %b %cmp2 = icmp ult i8 %a, %b @@ -1194,10 +1075,7 @@ define i1 @ule_ult(i8 %a, i8 %b) { define i1 @ult_eq(i8 %a, i8 %b) { ; CHECK-LABEL: @ult_eq( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp ult i8 %a, %b %cmp2 = icmp eq i8 %a, %b @@ -1208,9 +1086,7 @@ define i1 @ult_eq(i8 %a, i8 %b) { define i1 @ult_ne(i8 %a, i8 %b) { ; CHECK-LABEL: @ult_ne( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp ult i8 %a, %b %cmp2 = icmp ne i8 %a, %b @@ -1272,10 +1148,7 @@ define i1 @ult_slt(i8 %a, i8 %b) { define i1 @ult_uge(i8 %a, i8 %b) { ; CHECK-LABEL: @ult_uge( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp ult i8 %a, %b %cmp2 = icmp uge i8 %a, %b @@ -1285,10 +1158,7 @@ define i1 @ult_uge(i8 %a, i8 %b) { define i1 @ult_ugt(i8 %a, i8 %b) { ; CHECK-LABEL: @ult_ugt( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 false ; %cmp1 = icmp ult i8 %a, %b %cmp2 = icmp ugt i8 %a, %b @@ -1299,9 +1169,7 @@ define i1 @ult_ugt(i8 %a, i8 %b) { define i1 @ult_ule(i8 %a, i8 %b) { ; CHECK-LABEL: @ult_ule( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ule i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp ult i8 %a, %b %cmp2 = icmp ule i8 %a, %b @@ -1312,9 +1180,7 @@ define i1 @ult_ule(i8 %a, i8 %b) { define i1 @ult_ult(i8 %a, i8 %b) { ; CHECK-LABEL: @ult_ult( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b -; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret i1 [[AND]] +; CHECK-NEXT: ret i1 [[CMP1]] ; %cmp1 = icmp ult i8 %a, %b %cmp2 = icmp ult i8 %a, %b @@ -1326,10 +1192,7 @@ define i1 @ult_ult(i8 %a, i8 %b) { define <2 x i1> @ult_uge_vec(<2 x i8> %a, <2 x i8> %b) { ; CHECK-LABEL: @ult_uge_vec( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <2 x i8> %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp uge <2 x i8> %a, %b -; CHECK-NEXT: [[AND:%.*]] = and <2 x i1> [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret <2 x i1> [[AND]] +; CHECK-NEXT: ret <2 x i1> zeroinitializer ; %cmp1 = icmp ult <2 x i8> %a, %b %cmp2 = icmp uge <2 x i8> %a, %b @@ -1340,9 +1203,7 @@ define <2 x i1> @ult_uge_vec(<2 x i8> %a, <2 x i8> %b) { define <2 x i1> @ult_ule_vec(<2 x i8> %a, <2 x i8> %b) { ; CHECK-LABEL: @ult_ule_vec( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <2 x i8> %a, %b -; CHECK-NEXT: [[CMP2:%.*]] = icmp ule <2 x i8> %a, %b -; CHECK-NEXT: [[AND:%.*]] = and <2 x i1> [[CMP1]], [[CMP2]] -; CHECK-NEXT: ret <2 x i1> [[AND]] +; CHECK-NEXT: ret <2 x i1> [[CMP1]] ; %cmp1 = icmp ult <2 x i8> %a, %b %cmp2 = icmp ule <2 x i8> %a, %b -- 2.7.4