Home | History | Annotate | Download | only in InstCombine

Lines Matching full:icmp

113 /// isSignBitCheck - Given an exploded icmp instruction, return true if the
142 /// Returns true if the exploded icmp can be expressed as a signed comparison
222 /// we can optimize "icmp eq (load (gep "foo", 0, i)), 0" into "icmp eq i, 3".
502 /// want to return 'i' for "icmp ne i, 0". Note that, in general, indices can
504 /// legal to codegen as "icmp ne (i*4), 0" (assuming A is a pointer to i32).
611 // and would change the result of the icmp.
724 // Only lower this if the icmp is the only user of the GEP or if we expect
739 /// FoldICmpAddOpCst - Fold "icmp pred (X+CI), X".
745 // elsewhere. icmp X+0, X -> icmp X, X
803 /// FoldICmpDivCst - Fold "icmp pred, ([su]div X, DivRHS), CmpRHS" where DivRHS
843 // Get the ICmp opcode
919 default: llvm_unreachable("Unhandled icmp opcode!");
961 /// FoldICmpShrCst - Handle "icmp(([al]shr X, cst1), cst2)".
1049 /// visitICmpInstWithInstAndIntCst - Handle "icmp (instr, intcst)".
1059 // Simplify icmp eq (trunc x to i8), 42 -> icmp eq x, 42|highbits if all
1077 case Instruction::Xor: // (icmp pred (xor X, XorCST), CI)
1108 // (icmp u/s (xor A SignBit), C) -> (icmp s/u A, (xor C SignBit))
1118 // (icmp u/s (xor A ~SignBit), C) -> (icmp s/u (xor C ~SignBit), A)
1130 // (icmp ugt (xor X, C), ~C) -> (icmp ult X, C)
1136 // (icmp ult (xor X, C), -C) -> (icmp uge X, C)
1143 case Instruction::And: // (icmp pred (and X, AndCST), RHS)
1172 // should fold the icmp to true/false in that case.
1308 // Simplify icmp eq (or (ptrtoint P), (ptrtoint Q)), 0
1309 // -> and (icmp eq P, null), (icmp eq Q, null).
1324 case Instruction::Mul: { // (icmp pred (mul X, Val), CI)
1341 case Instruction::Shl: { // (icmp pred (shl X, ShAmt), CI)
1483 // Transform (icmp pred iM (shl iM %v, N), CI)
1484 // -> (icmp pred i(M-N) (trunc %v iM to i(M-N)), (trunc (CI>>N))
1505 case Instruction::LShr: // (icmp pred (shr X, ShAmt), CI)
1524 // Fold: icmp pred ([us]div X, C1), C2 -> range test
1561 // Fold: icmp pred (add X, C1), C2
1737 // Handle icmp {eq|ne} <intrinsic>, intcst.
1771 /// visitICmpInstWithCastAndCast - Handle icmp (cast x to y), (cast/cst).
1781 // Turn icmp (ptrtoint x), (ptrtoint/c) into a compare of the input if the
1879 assert(ICI.getPredicate() == ICmpInst::ICMP_UGT && "ICmp should be folded!");
1884 /// I = icmp ugt (add (add A, B), CI2), CI1
1968 // The original icmp gets replaced with the overflow value.
1997 // The original icmp gets replaced with the overflow value.
2063 return CmpInst::Create(Instruction::ICmp, I.getPredicate(), V, Op1);
2067 return CmpInst::Create(Instruction::ICmp, I.getPredicate(), V, Op1);
2074 // icmp's with boolean values can always be turned into bitwise operations
2077 default: llvm_unreachable("Invalid icmp instruction!");
2078 case ICmpInst::ICMP_EQ: { // icmp eq i1 A, B -> ~(A^B)
2082 case ICmpInst::ICMP_NE: // icmp eq i1 A, B -> A^B
2086 std::swap(Op0, Op1); // Change icmp ugt -> icmp ult
2088 case ICmpInst::ICMP_ULT:{ // icmp ult i1 A, B -> ~A & B
2093 std::swap(Op0, Op1); // Change icmp sgt -> icmp slt
2095 case ICmpInst::ICMP_SLT: { // icmp slt i1 A, B -> A & ~B
2100 std::swap(Op0, Op1); // Change icmp uge -> icmp ule
2102 case ICmpInst::ICMP_ULE: { // icmp ule i1 A, B -> ~A | B
2107 std::swap(Op0, Op1); // Change icmp sge -> icmp sle
2109 case ICmpInst::ICMP_SLE: { // icmp sle i1 A, B -> A | ~B
2141 ConstantInt *CI2; // I = icmp ugt (add (add A, B), CI2), CI
2148 // (icmp ne/eq (sub A B) 0) -> (icmp ne/eq A, B)
2151 // (icmp cond A B) if cond is equality
2155 // If we have an icmp le or icmp ge instruction, turn it into the
2156 // appropriate icmp lt or icmp gt instruction. This allows us to rely on
2230 default: llvm_unreachable("Unknown icmp opcode!");
2425 // instruction can be folded into the icmp
2431 // Handle icmp with constant (but not simple integer constant) RHS
2436 // icmp pred GEP (P, int 0, int 0, int 0), null -> icmp pred P, null
2443 // Only fold icmp into the PHI if the phi and icmp are in the same
2462 // fold to a constant (in which case the icmp is replaced with a select
2464 // select (in which case we are trading a select+icmp for a simpler
2465 // select+icmp).
2478 // icmp pred inttoptr(X), null -> icmp pred X, 0
2500 // If we can optimize a 'icmp GEP, P' or 'icmp P, GEP', do so now.
2509 // Test to see if the operands of the icmp are casted versions of other
2529 // Otherwise, cast the RHS right before the icmp
2538 // Handle the special case of: icmp (cast bool to X), <cst>
2572 // icmp (X+Y), X -> icmp Y, 0 for equalities or if there is no overflow.
2577 // icmp X, (X+Y) -> icmp 0, Y for equalities or if there is no overflow.
2582 // icmp (X+Y), (X+Z) -> icmp Y, Z for equalities or if there is no overflow.
2587 // Determine Y and Z in the form icmp (X+Y), (X+Z).
2610 // icmp slt (X + -1), Y -> icmp sle X, Y
2615 // icmp sge (X + -1), Y -> icmp sgt X, Y
2620 // icmp sle (X + 1), Y -> icmp slt X, Y
2625 // icmp sgt (X + 1), Y -> icmp sge X, Y
2631 // icmp (X + C1), (Y + C2) -> icmp (X + C3), Y
2635 // icmp (X + C1), (Y + C2) -> icmp X, (Y + C3)
2667 // icmp (X-Y), X -> icmp 0, Y for equalities or if there is no overflow.
2671 // icmp X, (X-Y) -> icmp
2675 // icmp (Y-X), (Z-X) -> icmp Y, Z for equalities or if there is no overflow.
2681 // icmp (X-Y), (X-Z) -> icmp Z, Y for equalities or if there is no overflow.
2688 // icmp (srem X, Y), Y
2692 // icmp Y, (srem X, Y)
2724 if (I.isEquality()) // a+x icmp eq/ne b+x --> a icmp b
2727 // icmp u/s (a ^ signbit), (b ^ signbit) --> icmp s/u a, b
2752 // a * Cst icmp eq/ne b * Cst --> a & Mask icmp b & Mask
2903 // Transform "icmp eq (trunc (lshr(X, cst1)), cst" to
2904 // "icmp (and X, mask), cst"
2931 // icmp X+Cst, X
2935 // icmp X, X+Cst