Home | History | Annotate | Download | only in InstCombine

Lines Matching refs:And

10 // This file implements the visitAnd, visitOr, and visitXor functions.
62 // Not expecting FCMP_FALSE and FCMP_TRUE;
67 /// This is the complement of getICmpCode, which turns an opcode and two
79 /// This is the complement of getFCmpCode, which turns an opcode and two
115 if (Op != Instruction::And && Op != Instruction::Or &&
146 if (Op == Instruction::And)
158 /// the Op parameter is 'OP', OpRHS is 'C1', and AndRHS is 'C2'. Op is
173 Value *And = Builder->CreateAnd(X, AndRHS);
174 And->takeName(Op);
175 return BinaryOperator::CreateXor(And, Together);
193 Value *And = Builder->CreateAnd(X, Together);
194 And->takeName(Op);
195 return BinaryOperator::CreateOr(And, OpRHS);
203 // of the bit. First thing to check is to see if this AND is with a
216 // If not, the only thing that can effect the output of the AND is
224 // Pull the XOR out of the AND.
235 // We know that the AND will not produce any of the bits shifted in, so if
245 return ReplaceInstUsesWith(TheAnd, Op); // No need for the and.
247 if (CI != AndRHS) { // Reducing bits set in and.
254 // We know that the AND will not produce any of the bits shifted in, so if
268 TheAnd.setOperand(1, CI); // Reduce bits set in and cst.
276 // with an and.
298 /// whether to treat the V, Lo and HI as signed or not. IB is the location to
345 /// so 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs. 0x0F0F0000 is
379 case Instruction::And:
387 // Otherwise, if Mask is 0+1+0+, and if B is known to have the low 0+
401 // If the AndRHS is a power of two minus one (0+1+), and N&Mask == 0
414 /// enum for classifying (icmp eq (A & B), C) and (icmp ne (A & B), C)
415 /// One of A and B is considered the mask, the other the value. This is
417 /// contains only "Mask", then both A and B can be considered masks.
419 /// is trivial if C == A, or C == 0. If both A and C are constants, this
428 /// The part "Mixed" declares, that (A & B) == C and C might or might not
429 /// contain any number of one bits and zero bits.
465 // if C is zero, then both A and B qualify as mask
588 /// that both LHS and RHS satisfy.
601 // and L11 & L12 == L21 & L22. The same goes for RHS.
602 // Now we must find those components L** and R**, that are equal, so
603 // that we can extract the parameters A, B, C, D, and E for the canonical
722 // input and output).
739 // with B and D, having a single bit set
758 // Remaining cases assume at least that B and D are constant, and depend on
767 // (icmp ne (A & B), 0) & (icmp ne (A & D), 0) and
795 // C and E, which are shared by both the mask B and the mask D, don't
798 // Currently, we only handle the case of B, C, D, and E being constant.
799 // we can't simply use C and E, because we might actually handle
801 // with B and D, having a single bit set
931 // (trunc x) == C1 & (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2
933 // iff the lower bits of C2 and CA are zero.
939 // (trunc x) == C1 & (and x, CA) == C2
940 // (and x, CA) == C2 & (trunc x) == C1
1007 // comparing a value against two constants and and'ing the result
1009 // icmp eq, icmp ne, icmp [su]lt, and icmp [SU]gt here. We also know
1011 // are not equal and that the larger constant is on the RHS
1208 assert((Opcode == Instruction::And || Opcode == Instruction::Or) &&
1209 and/or");
1211 if (Opcode == Instruction::And)
1214 Opcode = Instruction::And;
1324 // (A - N) & AndRHS -> -N & AndRHS iff A&AndRHS==0 and AndRHS
1355 // If this is an integer truncation, and if the source is an 'and' with
1360 // Change: and (trunc (and X, YC) to T), C2
1361 // into : and (trunc X to T), trunc(YC) & C2
1364 Value *NewCast = Builder->CreateTrunc(X, I.getType(), "and.shrunk");
1371 // Try to fold constant and into select arguments.
1416 // A is originally -1 (or a vector of -1 and undefs), then we enter
1463 // number of 'and' instructions might have to be created.
1483 // If and'ing two fcmp, try combine them into one.
1493 // fold (and (cast A), (cast B)) -> (cast (and A, B))
1507 // If this is and(cast(icmp), cast(icmp)), try to fold this even if the
1514 // If this is and(cast(fcmp), cast(fcmp)), try to fold this even if the
1524 // this to the canonical fabs intrinsic call and cast back to integer.
1547 // Fold (and (sext bool to A), B) --> (select bool, B, 0)
1554 // Fold (and ~(sext bool to A), B) --> (select bool, 0, B)
1569 /// Analyze the specified subexpression and see if it is capable of providing
1573 /// value. This function is recursive, and the end result is a mapping of
1575 /// validate that all `value`s are identical and that the bitnumber to bitnumber
1580 /// result and that all other bits are zero. This expression is accepted,
1581 /// BitValues[24-31] are set to %X and BitProvenance[24-31] are set to [0-7].
1583 /// This function returns true if the match was unsuccessful and false if so.
1607 // and BitMask adjusted.
1635 // If this is a logical 'and' with a mask that clears bits, clear the
1637 if (I->getOpcode() == Instruction::And &&
1645 // the and mask is.
1664 // Okay, we got to something that isn't a shift, 'or' or 'and'. This must be
1695 // Convert from bit indices to byte indices and check for a byte reversal.
1708 /// idiom. If so, insert the new intrinsic and return it.
1755 /// and either B or D is ~(cond?-1,0) or (cond?0,-1), then we can simplify this
1785 // if K1 and K2 are a one-bit mask.
1795 LAnd->getOpcode() == Instruction::And &&
1796 RAnd->getOpcode() == Instruction::And) {
1824 // [MAX_UINT-C1+1, MAX_UINT-C1+1+C3] and [MAX_UINT-C2+1, MAX_UINT-C2+1+C3]
1826 // 1) C1 and C2 is unsigned greater than C3.
1829 // 4) LowRange1 ^ LowRange2 and HighRange1 ^ HighRange2 are one-bit mask.
1981 // comparing a value against two constants and or'ing the result
1983 // ICMP_EQ, ICMP_NE, ICMP_LT, and ICMP_GT here. We also know (from the
1995 // if LHSCst and RHSCst differ only by one bit:
2275 // Try to fold constant and into select arguments.
2288 // (A | B) | C and A | (B | C) -> bswap if possible.
2291 // (A >> B) | (C << D) and (A << B) | (B >> C) -> bswap if possible.
2350 // iff (C1&C2) == 0 and (N&~C1) == 0
2368 // iff (C1&C2) == 0 and (C3&~C1) == 0 and (C4&~C2) == 0.
2381 // (A & (C0?-1:0)) | (B & ~(C0?-1:0)) -> C0 ? A : B, and commuted variants.
2641 if (Op0I->getOpcode() == Instruction::And ||
2651 if (Op0I->getOpcode() == Instruction::And)
2666 if (Op0I->getOpcode() == Instruction::And)
2689 // fold (xor(zext(cmp)), 1) and (xor(sext(cmp)), -1) to ext(!cmp).
2734 // Anything in both C1 and C2 is known to be zero, remove it from
2769 // Try to fold constant and into select arguments.