Home | History | Annotate | Download | only in InstCombine

Lines Matching refs:ICmp

113 /// isSignBitCheck - Given an exploded icmp instruction, return true if the
197 /// we can optimize "icmp eq (load (gep "foo", 0, i)), 0" into "icmp eq i, 3".
468 /// want to return 'i' for "icmp ne i, 0". Note that, in general, indices can
470 /// legal to codegen as "icmp ne (i*4), 0" (assuming A is a pointer to i32).
577 // and would change the result of the icmp.
692 // Only lower this if the icmp is the only user of the GEP or if we expect
707 /// FoldICmpAddOpCst - Fold "icmp pred (X+CI), X".
713 // elsewhere. icmp X+0, X -> icmp X, X
771 /// FoldICmpDivCst - Fold "icmp pred, ([su]div X, DivRHS), CmpRHS" where DivRHS
811 // Get the ICmp opcode
887 default: llvm_unreachable("Unhandled icmp opcode!");
929 /// FoldICmpShrCst - Handle "icmp(([al]shr X, cst1), cst2)".
1018 /// visitICmpInstWithInstAndIntCst - Handle "icmp (instr, intcst)".
1028 // Simplify icmp eq (trunc x to i8), 42 -> icmp eq x, 42|highbits if all
1046 case Instruction::Xor: // (icmp pred (xor X, XorCST), CI)
1077 // (icmp u/s (xor A SignBit), C) -> (icmp s/u A, (xor C SignBit))
1088 // (icmp u/s (xor A ~SignBit), C) -> (icmp s/u (xor C ~SignBit), A)
1102 case Instruction::And: // (icmp pred (and X, AndCST), RHS)
1131 // should fold the icmp to true/false in that case.
1260 // Simplify icmp eq (or (ptrtoint P), (ptrtoint Q)), 0
1261 // -> and (icmp eq P, null), (icmp eq Q, null).
1276 case Instruction::Shl: { // (icmp pred (shl X, ShAmt), CI)
1335 // Transform (icmp pred iM (shl iM %v, N), CI)
1336 // -> (icmp pred i(M-N) (trunc %v iM to i(M-N)), (trunc (CI>>N))
1357 case Instruction::LShr: // (icmp pred (shr X, ShAmt), CI)
1376 // Fold: icmp pred ([us]div X, C1), C2 -> range test
1389 // Fold: icmp pred (add X, C1), C2
1538 // Handle icmp {eq|ne} <intrinsic>, intcst.
1572 /// visitICmpInstWithCastAndCast - Handle icmp (cast x to y), (cast/cst).
1582 // Turn icmp (ptrtoint x), (ptrtoint/c) into a compare of the input if the
1680 assert(ICI.getPredicate() == ICmpInst::ICMP_UGT && "ICmp should be folded!");
1685 /// I = icmp ugt (add (add A, B), CI2), CI1
1769 // The original icmp gets replaced with the overflow value.
1798 // The original icmp gets replaced with the overflow value.
1864 return CmpInst::Create(Instruction::ICmp, I.getPredicate(), V, Op1);
1868 return CmpInst::Create(Instruction::ICmp, I.getPredicate(), V, Op1);
1875 // icmp's with boolean values can always be turned into bitwise operations
1878 default: llvm_unreachable("Invalid icmp instruction!");
1879 case ICmpInst::ICMP_EQ: { // icmp eq i1 A, B -> ~(A^B)
1883 case ICmpInst::ICMP_NE: // icmp eq i1 A, B -> A^B
1887 std::swap(Op0, Op1); // Change icmp ugt -> icmp ult
1889 case ICmpInst::ICMP_ULT:{ // icmp ult i1 A, B -> ~A & B
1894 std::swap(Op0, Op1); // Change icmp sgt -> icmp slt
1896 case ICmpInst::ICMP_SLT: { // icmp slt i1 A, B -> A & ~B
1901 std::swap(Op0, Op1); // Change icmp uge -> icmp ule
1903 case ICmpInst::ICMP_ULE: { // icmp ule i1 A, B -> ~A | B
1908 std::swap(Op0, Op1); // Change icmp sge -> icmp sle
1910 case ICmpInst::ICMP_SLE: { // icmp sle i1 A, B -> A | ~B
1942 ConstantInt *CI2; // I = icmp ugt (add (add A, B), CI2), CI
1949 // (icmp ne/eq (sub A B) 0) -> (icmp ne/eq A, B)
1952 // (icmp cond A B) if cond is equality
1956 // If we have an icmp le or icmp ge instruction, turn it into the
1957 // appropriate icmp lt or icmp gt instruction. This allows us to rely on
2031 default: llvm_unreachable("Unknown icmp opcode!");
2226 // instruction can be folded into the icmp
2232 // Handle icmp with constant (but not simple integer constant) RHS
2237 // icmp pred GEP (P, int 0, int 0, int 0), null -> icmp pred P, null
2244 // Only fold icmp into the PHI if the phi and icmp are in the same
2263 // fold to a constant (in which case the icmp is replaced with a select
2265 // select (in which case we are trading a select+icmp for a simpler
2266 // select+icmp).
2279 // icmp pred inttoptr(X), null -> icmp pred X, 0
2301 // If we can optimize a 'icmp GEP, P' or 'icmp P, GEP', do so now.
2310 // Test to see if the operands of the icmp are casted versions of other
2330 // Otherwise, cast the RHS right before the icmp
2339 // Handle the special case of: icmp (cast bool to X), <cst>
2373 // icmp (X+Y), X -> icmp Y, 0 for equalities or if there is no overflow.
2378 // icmp X, (X+Y) -> icmp 0, Y for equalities or if there is no overflow.
2383 // icmp (X+Y), (X+Z) -> icmp Y, Z for equalities or if there is no overflow.
2388 // Determine Y and Z in the form icmp (X+Y), (X+Z).
2419 // icmp (X-Y), X -> icmp 0, Y for equalities or if there is no overflow.
2423 // icmp X, (X-Y) -> icmp Y, 0 for equalities or if there is no overflow.
2427 // icmp (Y-X), (Z-X) -> icmp Y, Z for equalities or if there is no overflow.
2433 // icmp (X-Y), (X-Z) -> icmp Z, Y for equalities or if there is no overflow.
2440 // icmp (srem X, Y), Y
2444 // icmp Y, (srem X, Y)
2476 if (I.isEquality()) // a+x icmp eq/ne b+x --> a icmp b
2479 // icmp u/s (a ^ signbit), (b ^ signbit) --> icmp s/u a, b
2504 // a * Cst icmp eq/ne b * Cst --> a & Mask icmp b & Mask
2647 // Transform "icmp eq (trunc (lshr(X, cst1)), cst" to
2648 // "icmp (and X, mask), cst"
2675 // icmp X+Cst, X
2679 // icmp X, X+Cst