diff options
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 9934c065ebf8..6c2554ea73b7 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -95,8 +95,8 @@ Value *InstCombinerImpl::EvaluateInDifferentType(Value *V, Type *Ty, default: llvm_unreachable("Unsupported call!"); case Intrinsic::vscale: { - Function *Fn = - Intrinsic::getDeclaration(I->getModule(), Intrinsic::vscale, {Ty}); + Function *Fn = Intrinsic::getOrInsertDeclaration( + I->getModule(), Intrinsic::vscale, {Ty}); Res = CallInst::Create(Fn->getFunctionType(), Fn); break; } @@ -600,7 +600,8 @@ Instruction *InstCombinerImpl::narrowFunnelShift(TruncInst &Trunc) { if (ShVal0 != ShVal1) Y = Builder.CreateTrunc(ShVal1, DestTy); Intrinsic::ID IID = IsFshl ? Intrinsic::fshl : Intrinsic::fshr; - Function *F = Intrinsic::getDeclaration(Trunc.getModule(), IID, DestTy); + Function *F = + Intrinsic::getOrInsertDeclaration(Trunc.getModule(), IID, DestTy); return CallInst::Create(F, {X, Y, NarrowShAmt}); } @@ -1912,8 +1913,8 @@ Instruction *InstCombinerImpl::visitFPTrunc(FPTruncInst &FPT) { // Do unary FP operation on smaller type. // (fptrunc (fabs x)) -> (fabs (fptrunc x)) Value *InnerTrunc = Builder.CreateFPTrunc(Src, Ty); - Function *Overload = Intrinsic::getDeclaration(FPT.getModule(), - II->getIntrinsicID(), Ty); + Function *Overload = Intrinsic::getOrInsertDeclaration( + FPT.getModule(), II->getIntrinsicID(), Ty); SmallVector<OperandBundleDef, 1> OpBundles; II->getOperandBundlesAsDefs(OpBundles); CallInst *NewCI = @@ -2855,8 +2856,8 @@ Instruction *InstCombinerImpl::visitBitCast(BitCastInst &CI) { if (IntrinsicNum != 0) { assert(ShufOp0->getType() == SrcTy && "Unexpected shuffle mask"); assert(match(ShufOp1, m_Undef()) && "Unexpected shuffle op"); - Function *BswapOrBitreverse = - Intrinsic::getDeclaration(CI.getModule(), IntrinsicNum, DestTy); + Function *BswapOrBitreverse = Intrinsic::getOrInsertDeclaration( + CI.getModule(), IntrinsicNum, DestTy); Value *ScalarX = Builder.CreateBitCast(ShufOp0, DestTy); return CallInst::Create(BswapOrBitreverse, {ScalarX}); } |
