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();
441 Instruction *InstCombinerImpl::narrowFunnelShift(TruncInst &Trunc) {
442 assert((isa<VectorType>(Trunc.getSrcTy()) ||
443 shouldChangeType(Trunc.getSrcTy(), Trunc.getType())) &&
448 Type *DestTy = Trunc.getType();
450 unsigned WideWidth = Trunc.getSrcTy()->getScalarSizeInBits();
457 if (!match(Trunc.getOperand(0), m_OneUse(m_Or(m_BinOp(Or0), m_BinOp(Or1)))))
523 if (!MaskedValueIsZero(ShVal1, HiBitMask, 0, &Trunc))
538 Function *F = Intrinsic::getDeclaration(Trunc.getModule(), IID, DestTy);
544 Instruction *InstCombinerImpl::narrowBinOp(TruncInst &Trunc) {
545 Type *SrcTy = Trunc.getSrcTy();
546 Type *DestTy = Trunc.getType();
554 if (!match(Trunc.getOperand(0), m_OneUse(m_BinOp(BinOp))))
603 auto *OldShift = cast<Instruction>(Trunc.getOperand(0));
621 if (Instruction *NarrowOr = narrowFunnelShift(Trunc))
630 static Instruction *shrinkSplatShuffle(TruncInst &Trunc,
632 auto *Shuf = dyn_cast<ShuffleVectorInst>(Trunc.getOperand(0));
638 Value *NarrowOp = Builder.CreateTrunc(Shuf->getOperand(0), Trunc.getType());
650 static Instruction *shrinkInsertElt(CastInst &Trunc,
652 Instruction::CastOps Opcode = Trunc.getOpcode();
653 assert((Opcode == Instruction::Trunc || Opcode == Instruction::FPTrunc) &&
656 auto *InsElt = dyn_cast<InsertElementInst>(Trunc.getOperand(0));
660 Type *DestTy = Trunc.getType();
677 Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
678 if (Instruction *Result = commonCastTransforms(Trunc))
681 Value *Src = Trunc.getOperand(0);
682 Type *DestTy = Trunc.getType(), *SrcTy = Src->getType();
691 canEvaluateTruncated(Src, DestTy, *this, &Trunc)) {
698 << Trunc << '\n');
701 return replaceInstUsesWith(Trunc, Res);
712 canEvaluateTruncated(Src, NewDestTy, *this, &Trunc)) {
716 << Trunc << '\n');
734 if (SimplifyDemandedInstructionBits(Trunc))
735 return &Trunc;
776 if (Trunc.hasNoUnsignedWrap() || Trunc.hasNoSignedWrap()) {
800 return ConstantFoldCastOperand(Instruction::Trunc, ShAmt, A->getType(),
822 if (Instruction *I = narrowBinOp(Trunc))
825 if (Instruction *I = shrinkSplatShuffle(Trunc, Builder))
828 if (Instruction *I = shrinkInsertElt(Trunc, Builder))
848 if (Instruction *I = foldVecTruncToExtElt(Trunc, *this))
889 Builder.CreateIntrinsic(Intrinsic::ctlz, {Trunc.getType()}, {A, B});
895 if (Trunc.getFunction() &&
896 Trunc.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
898 Trunc.getFunction()->getFnAttribute(Attribute::VScaleRange);
902 return replaceInstUsesWith(Trunc, VScale);
909 if (!Trunc.hasNoSignedWrap() &&
910 ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) {
911 Trunc.setHasNoSignedWrap(true);
914 if (!Trunc.hasNoUnsignedWrap() &&
916 /*Depth=*/0, &Trunc)) {
917 Trunc.setHasNoUnsignedWrap(true);
921 return Changed ? &Trunc : nullptr;
1038 case Instruction::Trunc: // zext(trunc(x)) -> trunc(x) or zext(x)
1222 Value *Trunc = Builder.CreateTrunc(A, DestTy);
1224 return BinaryOperator::CreateAnd(Trunc,
1225 ConstantInt::get(Trunc->getType(),
1392 case Instruction::Trunc: // sext(trunc(x)) -> trunc(x) or sext(x)