Home | History | Annotate | Download | only in InstCombine

Lines Matching refs:LHS

97 static Value *getNewICmpValue(bool Sign, unsigned Code, Value *LHS, Value *RHS,
100 if (Value *NewConstant = getICmpValue(Sign, Code, LHS, RHS, NewPred))
102 return Builder->CreateICmp(NewPred, LHS, RHS);
109 Value *LHS, Value *RHS,
122 if (!isordered) return ConstantInt::getTrue(LHS->getContext());
125 return Builder->CreateFCmp(Pred, LHS, RHS);
334 /// FoldLogicalPlusAnd - This is part of an expression (LHS +/- RHS) & Mask,
344 Value *InstCombiner::FoldLogicalPlusAnd(Value *LHS, Value *RHS,
347 Instruction *LHSI = dyn_cast<Instruction>(LHS);
533 /// that both LHS and RHS satisfy
537 ICmpInst *LHS, ICmpInst *RHS,
540 if (LHS->getOperand(0)->getType() != RHS->getOperand(0)->getType()) return 0;
542 if (LHS->getOperand(0)->getType()->isVectorTy()) return 0;
545 // LHS might be of the form L11 & L12 == X, X == L21 & L22,
550 Value *L1 = LHS->getOperand(0);
551 Value *L2 = LHS->getOperand(1);
554 if (decomposeBitTestICmp(LHS, LHSCC, L11, L12, L2)) {
557 // Look for ANDs in the LHS icmp.
569 // Bail if LHS was a icmp that can't be decomposed into an equality.
631 static Value* foldLogOpOfMaskedICmps(ICmpInst *LHS, ICmpInst *RHS,
635 ICmpInst::Predicate LHSCC = LHS->getPredicate(), RHSCC = RHS->getPredicate();
636 unsigned mask = foldLogOpOfMaskedICmpsHelper(A, B, C, D, E, LHS, RHS,
710 Value *InstCombiner::FoldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
711 ICmpInst::Predicate LHSCC = LHS->getPredicate(), RHSCC = RHS->getPredicate();
715 if (LHS->getOperand(0) == RHS->getOperand(1) &&
716 LHS->getOperand(1) == RHS->getOperand(0))
717 LHS->swapOperands();
718 if (LHS->getOperand(0) == RHS->getOperand(0) &&
719 LHS->getOperand(1) == RHS->getOperand(1)) {
720 Value *Op0 = LHS->getOperand(0), *Op1 = LHS->getOperand(1);
721 unsigned Code = getICmpCode(LHS) & getICmpCode(RHS);
722 bool isSigned = LHS->isSigned() || RHS->isSigned();
728 if (Value *V = foldLogOpOfMaskedICmps(LHS, RHS, ICmpInst::ICMP_EQ, Builder))
732 Value *Val = LHS->getOperand(0), *Val2 = RHS->getOperand(0);
733 ConstantInt *LHSCst = dyn_cast<ConstantInt>(LHS->getOperand(1));
757 LHS->hasOneUse() && RHS->hasOneUse()) {
808 return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0);
824 std::swap(LHS, RHS);
845 return LHS;
876 return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0);
881 return LHS;
893 return LHS;
942 Value *InstCombiner::FoldAndOfFCmps(FCmpInst *LHS, FCmpInst *RHS) {
943 if (LHS->getPredicate() == FCmpInst::FCMP_ORD &&
946 if (ConstantFP *LHSC = dyn_cast<ConstantFP>(LHS->getOperand(1)))
951 return ConstantInt::getFalse(LHS->getContext());
952 return Builder->CreateFCmpORD(LHS->getOperand(0), RHS->getOperand(0));
957 if (isa<ConstantAggregateZero>(LHS->getOperand(1)) &&
959 return Builder->CreateFCmpORD(LHS->getOperand(0), RHS->getOperand(0));
963 Value *Op0LHS = LHS->getOperand(0), *Op0RHS = LHS->getOperand(1);
965 FCmpInst::Predicate Op0CC = LHS->getPredicate(), Op1CC = RHS->getPredicate();
969 // Swap RHS operands to match LHS.
979 return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0);
983 return LHS;
990 std::swap(LHS, RHS);
1003 return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0);
1045 // Not masking anything out for the LHS, move to RHS.
1052 // Not masking anything out for the RHS, move to LHS.
1194 if (ICmpInst *LHS = dyn_cast<ICmpInst>(Op0))
1195 if (Value *Res = FoldAndOfICmps(LHS, RHS))
1199 if (FCmpInst *LHS = dyn_cast<FCmpInst>(I.getOperand(0)))
1201 if (Value *Res = FoldAndOfFCmps(LHS, RHS))
1224 if (ICmpInst *LHS = dyn_cast<ICmpInst>(Op0COp))
1225 if (Value *Res = FoldAndOfICmps(LHS, RHS))
1231 if (FCmpInst *LHS = dyn_cast<FCmpInst>(Op0COp))
1232 if (Value *Res = FoldAndOfFCmps(LHS, RHS))
1434 Value *InstCombiner::FoldOrOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
1435 ICmpInst::Predicate LHSCC = LHS->getPredicate(), RHSCC = RHS->getPredicate();
1439 if (LHS->getOperand(0) == RHS->getOperand(1) &&
1440 LHS->getOperand(1) == RHS->getOperand(0))
1441 LHS->swapOperands();
1442 if (LHS->getOperand(0) == RHS->getOperand(0) &&
1443 LHS->getOperand(1) == RHS->getOperand(1)) {
1444 Value *Op0 = LHS->getOperand(0), *Op1 = LHS->getOperand(1);
1445 unsigned Code = getICmpCode(LHS) | getICmpCode(RHS);
1446 bool isSigned = LHS->isSigned() || RHS->isSigned();
1453 if (Value *V = foldLogOpOfMaskedICmps(LHS, RHS, ICmpInst::ICMP_NE, Builder))
1457 Value *Val = LHS->getOperand(0), *Val2 = RHS->getOperand(0);
1458 ConstantInt *LHSCst = dyn_cast<ConstantInt>(LHS->getOperand(1));
1504 std::swap(LHS, RHS);
1546 return LHS;
1550 return ConstantInt::getTrue(LHS->getContext());
1561 return LHS;
1581 LHS;
1597 return LHS;
1602 return ConstantInt::getTrue(LHS->getContext());
1612 return LHS;
1617 return ConstantInt::getTrue(LHS->getContext());
1629 Value *InstCombiner::FoldOrOfFCmps(FCmpInst *LHS, FCmpInst *RHS) {
1630 if (LHS->getPredicate() == FCmpInst::FCMP_UNO &&
1632 LHS->getOperand(0)->getType() == RHS->getOperand(0)->getType()) {
1633 if (ConstantFP *LHSC = dyn_cast<ConstantFP>(LHS->getOperand(1)))
1638 return ConstantInt::getTrue(LHS->getContext());
1642 return Builder->CreateFCmpUNO(LHS->getOperand(0), RHS->getOperand(0));
1647 if (isa<ConstantAggregateZero>(LHS->getOperand(1)) &&
1649 return Builder->CreateFCmpUNO(LHS->getOperand(0), RHS->getOperand(0));
1654 Value *Op0LHS = LHS->getOperand(0), *Op0RHS = LHS->getOperand(1);
1656 FCmpInst::Predicate Op0CC = LHS->getPredicate(), Op1CC = RHS->getPredicate();
1659 // Swap RHS operands to match LHS.
1668 return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 1);
1672 return LHS;
1966 if (ICmpInst *LHS = dyn_cast<ICmpInst>(I.getOperand(0)))
1967 if (Value *Res = FoldOrOfICmps(LHS, RHS))
1971 if (FCmpInst *LHS = dyn_cast<FCmpInst>(I.getOperand(0)))
1973 if (Value *Res = FoldOrOfFCmps(LHS, RHS))
1997 if (ICmpInst *LHS = dyn_cast<ICmpInst>(Op0COp))
1998 if (Value *Res = FoldOrOfICmps(LHS, RHS))
2004 if (FCmpInst *LHS = dyn_cast<FCmpInst>(Op0COp))
2005 if (Value *Res = FoldOrOfFCmps(LHS, RHS))
2241 if (ICmpInst *LHS = dyn_cast<ICmpInst>(I.getOperand(0)))
2242 if (PredicatesFoldable(LHS->getPredicate(), RHS->getPredicate())) {
2243 if (LHS->getOperand(0) == RHS->getOperand(1) &&
2244 LHS->getOperand(1) == RHS->getOperand(0))
2245 LHS->swapOperands();
2246 if (LHS->getOperand(0) == RHS->getOperand(0) &&
2247 LHS->getOperand(1) == RHS->getOperand(1)) {
2248 Value *Op0 = LHS->getOperand(0), *Op1 = LHS->getOperand(1);
2249 unsigned Code = getICmpCode(LHS) ^ getICmpCode(RHS);
2250 bool isSigned = LHS->isSigned() || RHS->isSigned();