Lines Matching defs:C2

228     Constant *C1, *C2;
230 if (match(&I, m_Mul(m_Shl(m_Value(NewOp), m_ImmConstant(C2)),
233 // ((X << C2)*C1) == (X * (C1 << C2))
235 ConstantFoldBinaryOpOperands(Instruction::Shl, C1, C2, DL);
716 // further folds and (X * C) + C2 is 'fma'.
1052 static bool multiplyOverflows(const APInt &C1, const APInt &C2, APInt &Product,
1055 Product = IsSigned ? C1.smul_ov(C2, Overflow) : C1.umul_ov(C2, Overflow);
1059 /// True if C1 is a multiple of C2. Quotient contains C1/C2.
1060 static bool isMultiple(const APInt &C1, const APInt &C2, APInt &Quotient,
1062 assert(C1.getBitWidth() == C2.getBitWidth() && "Constant widths not equal");
1065 if (C2.isZero())
1069 if (IsSigned && C1.isMinSignedValue() && C2.isAllOnes())
1074 APInt::sdivrem(C1, C2, Quotient, Remainder);
1076 APInt::udivrem(C1, C2, Quotient, Remainder);
1192 const APInt *C2;
1193 if (match(Op1, m_APInt(C2))) {
1197 // (X / C1) / C2 -> X / (C1*C2)
1201 if (!multiplyOverflows(*C1, *C2, Product, IsSigned))
1206 APInt Quotient(C2->getBitWidth(), /*val=*/0ULL, IsSigned);
1210 // (X * C1) / C2 -> X / (C2 / C1) if C2 is a multiple of C1.
1211 if (isMultiple(*C2, *C1, Quotient, IsSigned)) {
1218 // (X * C1) / C2 -> X * (C1 / C2) if C1 is a multiple of C2.
1219 if (isMultiple(*C1, *C2, Quotient, IsSigned)) {
1236 // (X << C1) / C2 -> X / (C2 >> C1) if C2 is a multiple of 1 << C1.
1237 if (isMultiple(*C2, C1Shifted, Quotient, IsSigned)) {
1244 // (X << C1) / C2 -> X * ((1 << C1) / C2) if 1 << C1 is a multiple of C2.
1245 if (isMultiple(C1Shifted, *C2, Quotient, IsSigned)) {
1256 // ((X * C2) + C1) / C2 --> X + C1/C2
1260 match(Op0, m_NSWAddLike(m_NSWMul(m_Value(X), m_SpecificInt(*C2)),
1262 isMultiple(*C1, *C2, Quotient, IsSigned)) {
1266 match(Op0, m_NUWAddLike(m_NUWMul(m_Value(X), m_SpecificInt(*C2)),
1269 ConstantInt::get(Ty, C1->udiv(*C2)));
1272 if (!C2->isZero()) // avoid X udiv 0
1369 const APInt *C1, *C2;
1377 if (match(A, m_APInt(C1)) && match(B, m_APInt(C2)) && C2->ule(*C1))
1528 const APInt *C1, *C2;
1529 if (match(Op0, m_LShr(m_Value(X), m_APInt(C1))) && match(Op1, m_APInt(C2))) {
1530 // (X lshr C1) udiv C2 --> X udiv (C2 << C1)
1532 APInt C2ShlC1 = C2->ushl_ov(*C1, Overflow);
1784 Constant *C2, *NewC = nullptr;
1785 if (match(I.getOperand(1), m_FMul(m_Value(X), m_Constant(C2)))) {
1786 // C / (X * C2) --> (C / C2) / X
1787 NewC = ConstantFoldBinaryOpOperands(Instruction::FDiv, C, C2, DL);
1788 } else if (match(I.getOperand(1), m_FDiv(m_Value(X), m_Constant(C2)))) {
1789 // C / (X / C2) --> (C * C2) / X
1790 NewC = ConstantFoldBinaryOpOperands(Instruction::FMul, C, C2, DL);