Lines Matching defs:Trunc

56   case Instruction::Trunc:
183 (CI.getOpcode() == Instruction::Trunc &&
349 case Instruction::Trunc:
401 static Instruction *foldVecTruncToExtElt(TruncInst &Trunc,
403 Value *TruncOp = Trunc.getOperand(0);
404 Type *DestType = Trunc.getType();
451 static Instruction *foldVecExtTruncToExtElt(TruncInst &Trunc,
453 Value *Src = Trunc.getOperand(0);
455 Type *DstType = Trunc.getType();
506 Instruction *InstCombinerImpl::narrowFunnelShift(TruncInst &Trunc) {
507 assert((isa<VectorType>(Trunc.getSrcTy()) ||
508 shouldChangeType(Trunc.getSrcTy(), Trunc.getType())) &&
513 Type *DestTy = Trunc.getType();
515 unsigned WideWidth = Trunc.getSrcTy()->getScalarSizeInBits();
522 if (!match(Trunc.getOperand(0), m_OneUse(m_Or(m_BinOp(Or0), m_BinOp(Or1)))))
588 if (!MaskedValueIsZero(ShVal1, HiBitMask, 0, &Trunc))
604 Intrinsic::getOrInsertDeclaration(Trunc.getModule(), IID, DestTy);
610 Instruction *InstCombinerImpl::narrowBinOp(TruncInst &Trunc) {
611 Type *SrcTy = Trunc.getSrcTy();
612 Type *DestTy = Trunc.getType();
620 if (!match(Trunc.getOperand(0), m_OneUse(m_BinOp(BinOp))))
669 auto *OldShift = cast<Instruction>(Trunc.getOperand(0));
687 if (Instruction *NarrowOr = narrowFunnelShift(Trunc))
696 static Instruction *shrinkSplatShuffle(TruncInst &Trunc,
698 auto *Shuf = dyn_cast<ShuffleVectorInst>(Trunc.getOperand(0));
704 Value *NarrowOp = Builder.CreateTrunc(Shuf->getOperand(0), Trunc.getType());
716 static Instruction *shrinkInsertElt(CastInst &Trunc,
718 Instruction::CastOps Opcode = Trunc.getOpcode();
719 assert((Opcode == Instruction::Trunc || Opcode == Instruction::FPTrunc) &&
722 auto *InsElt = dyn_cast<InsertElementInst>(Trunc.getOperand(0));
726 Type *DestTy = Trunc.getType();
743 Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
744 if (Instruction *Result = commonCastTransforms(Trunc))
747 Value *Src = Trunc.getOperand(0);
748 Type *DestTy = Trunc.getType(), *SrcTy = Src->getType();
757 canEvaluateTruncated(Src, DestTy, *this, &Trunc)) {
764 << Trunc << '\n');
767 return replaceInstUsesWith(Trunc, Res);
778 canEvaluateTruncated(Src, NewDestTy, *this, &Trunc)) {
782 << Trunc << '\n');
791 if (SimplifyDemandedInstructionBits(Trunc))
792 return &Trunc;
833 if (Trunc.hasNoUnsignedWrap() || Trunc.hasNoSignedWrap()) {
857 return ConstantFoldCastOperand(Instruction::Trunc, ShAmt, A->getType(),
879 if (Instruction *I = narrowBinOp(Trunc))
882 if (Instruction *I = shrinkSplatShuffle(Trunc, Builder))
885 if (Instruction *I = shrinkInsertElt(Trunc, Builder))
905 if (Instruction *I = foldVecTruncToExtElt(Trunc, *this))
908 if (Instruction *I = foldVecExtTruncToExtElt(Trunc, *this))
918 Builder.CreateIntrinsic(Intrinsic::ctlz, {Trunc.getType()}, {A, B});
924 if (Trunc.getFunction() &&
925 Trunc.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
927 Trunc.getFunction()->getFnAttribute(Attribute::VScaleRange);
931 return replaceInstUsesWith(Trunc, VScale);
938 (Trunc.hasNoUnsignedWrap() || Trunc.hasNoSignedWrap()) &&
939 isKnownNonZero(Src, SQ.getWithInstruction(&Trunc)))
940 return replaceInstUsesWith(Trunc, ConstantInt::getTrue(DestTy));
943 if (!Trunc.hasNoSignedWrap() &&
944 ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) {
945 Trunc.setHasNoSignedWrap(true);
948 if (!Trunc.hasNoUnsignedWrap() &&
950 /*Depth=*/0, &Trunc)) {
951 Trunc.setHasNoUnsignedWrap(true);
955 return Changed ? &Trunc : nullptr;
1079 case Instruction::Trunc: // zext(trunc(x)) -> trunc(x) or zext(x)
1263 Value *Trunc = Builder.CreateTrunc(A, DestTy);
1265 return BinaryOperator::CreateAnd(Trunc,
1266 ConstantInt::get(Trunc->getType(),
1433 case Instruction::Trunc: // sext(trunc(x)) -> trunc(x) or sext(x)