Lines Matching defs:C1

336   Constant *C0, *C1;
337 if (!match(I.getOperand(1), m_Constant(C1)))
351 match(ConstantExpr::getAdd(C0, C1),
363 // shift (logic (shift X, C0), Y), C1 -> logic (shift X, C0+C1), (shift Y, C1)
364 Constant *ShiftSumC = ConstantExpr::getAdd(C0, C1);
366 Value *NewShift2 = Builder.CreateBinOp(ShiftOpcode, Y, C1);
404 // C shift (A add nuw C1) --> (C shift C1) shift A
406 Constant *C, *C1;
408 match(Op1, m_NUWAdd(m_Value(A), m_Constant(C1)))) {
409 Value *NewC = Builder.CreateBinOp(I.getOpcode(), C, C1);
473 /// that have constant shift amounts: OuterShift (InnerShift X, C1), C2.
485 // shl (shl X, C1), C2 --> shl X, C1 + C2
486 // lshr (lshr X, C1), C2 --> lshr X, C1 + C2
498 // lshr (shl X, C1), C2 --> and (shl X, C1 - C2), C3
499 // shl (lshr X, C1), C2 --> and (lshr X, C1 - C2), C3
579 /// Fold OuterShift (InnerShift X, C1), C2.
589 const APInt *C1;
590 match(InnerShift->getOperand(1), m_APInt(C1));
591 unsigned InnerShAmt = C1->getZExtValue();
606 // shl (shl X, C1), C2 --> shl X, C1 + C2
607 // lshr (lshr X, C1), C2 --> lshr X, C1 + C2
637 // lshr (shl X, C1), C2 --> shl X, C1 - C2
638 // shl (lshr X, C1), C2 --> lshr X, C1 - C2
723 Instruction *InstCombinerImpl::FoldShiftByConstant(Value *Op0, Constant *C1,
725 // (C2 << X) << C1 --> (C2 << C1) << X
726 // (C2 >> X) >> C1 --> (C2 >> C1) >> X
731 I.getOpcode(), Builder.CreateBinOp(I.getOpcode(), C2, C1), X);
740 if (!IsLeftShift && match(C1, m_SpecificIntAllowUndef(TypeBits - 1)) &&
753 if (!match(C1, m_APInt(Op1C)))
785 Builder.CreateBinOp(I.getOpcode(), Op0BO->getOperand(1), C1);
788 Builder.CreateBinOp(I.getOpcode(), Op0BO->getOperand(0), C1);
800 // shl (select C, (add X, C1), X), C2
803 // select C, (add Y, C1 << C2), Y
814 Builder.CreateBinOp(I.getOpcode(), TBO->getOperand(1), C1);
816 Value *NewShift = Builder.CreateBinOp(I.getOpcode(), FalseVal, C1);
831 Builder.CreateBinOp(I.getOpcode(), FBO->getOperand(1), C1);
833 Value *NewShift = Builder.CreateBinOp(I.getOpcode(), TrueVal, C1);
950 const APInt *C1;
951 if (match(Op0, m_Exact(m_Shr(m_Value(X), m_APInt(C1)))) &&
952 C1->ult(BitWidth)) {
953 unsigned ShrAmt = C1->getZExtValue();
955 // If C1 < C: (X >>?,exact C1) << C --> X << (C - C1)
963 // If C1 > C: (X >>?exact C1) << C --> X >>?exact (C1 - C)
972 if (match(Op0, m_OneUse(m_Shr(m_Value(X), m_APInt(C1)))) &&
973 C1->ult(BitWidth)) {
974 unsigned ShrAmt = C1->getZExtValue();
976 // If C1 < C: (X >>? C1) << C --> (X << (C - C1)) & (-1 << C)
986 // If C1 > C: (X >>? C1) << C --> (X >>? (C1 - C)) & (-1 << C)
1001 match(Shr, m_Shr(m_Value(X), m_APInt(C1)))) {
1003 unsigned ShrAmtC = C1->getZExtValue();
1008 // If C1 > C:
1009 // (trunc (X >> C1)) << C --> (trunc (X >> (C1 - C))) && (-1 << C)
1010 // If C > C1:
1011 // (trunc (X >> C1)) << C --> (trunc (X << (C - C1))) && (-1 << C)
1018 if (match(Op0, m_Shl(m_Value(X), m_APInt(C1))) && C1->ult(BitWidth)) {
1019 unsigned AmtSum = ShAmtC + C1->getZExtValue();
1022 // (X << C1) << C2 --> X << (C1 + C2)
1084 // (C1 - X) << C --> (C1 << C) - (X << C)
1085 if (match(Op0, m_OneUse(m_Sub(m_APInt(C1), m_Value(X))))) {
1086 Constant *NewLHS = ConstantInt::get(Ty, C1->shl(*C));
1115 Constant *C1;
1116 if (match(Op1, m_Constant(C1))) {
1119 // (X * C2) << C1 --> X * (C2 << C1)
1121 return BinaryOperator::CreateMul(X, ConstantExpr::getShl(C2, C1));
1123 // shl (zext i1 X), C1 --> select (X, 1 << C1, 0)
1125 auto *NewC = ConstantExpr::getShl(ConstantInt::get(Ty, 1), C1);
1188 const APInt *C1;
1189 if (match(Op0, m_Shl(m_Value(X), m_APInt(C1))) && C1->ult(BitWidth)) {
1190 if (C1->ult(ShAmtC)) {
1191 unsigned ShlAmtC = C1->getZExtValue();
1194 // (X <<nuw C1) >>u C --> X >>u (C - C1)
1200 // (X << C1) >>u C --> (X >>u (C - C1)) & (-1 >> C)
1205 } else if (C1->ugt(ShAmtC)) {
1206 unsigned ShlAmtC = C1->getZExtValue();
1209 // (X <<nuw C1) >>u C --> X <<nuw (C1 - C)
1215 // (X << C1) >>u C --> X << (C1 - C) & (-1 >> C)
1221 assert(*C1 == ShAmtC);
1297 // (X >>u C1) >>u C --> X >>u (C1 + C)
1298 if (match(Op0, m_LShr(m_Value(X), m_APInt(C1)))) {
1300 unsigned AmtSum = ShAmtC + C1->getZExtValue();
1307 match(TruncSrc, m_LShr(m_Value(X), m_APInt(C1)))) {
1309 unsigned AmtSum = ShAmtC + C1->getZExtValue();
1312 // (trunc (X >>u C1)) >>u C --> and (trunc (X >>u (C1 + C)), MaskC
1317 (TruncSrc->hasOneUse() || C1->uge(SrcWidth - BitWidth))) {
1428 Constant *C1, *C2;
1431 m_ZExtOrSelf(m_Sub(m_Constant(C1),
1435 !BitWidthSplat(C1, &OldAShr) || !BitWidthSplat(C2, &OldAShr))
1505 // We can't handle (X << C1) >>s C2. It shifts arbitrary bits in. However,
1506 // we can handle (X <<nsw C1) >>s C2 since it only shifts in sign bits.
1512 // (X <<nsw C1) >>s C2 --> X >>s (C2 - C1)
1519 // (X <<nsw C1) >>s C2 --> X <<nsw (C1 - C2)
1532 // (X >>s C1) >>s C2 --> X >>s (C1 + C2)