[llvm] [InstSimplify] Expose simplifyIntrinsic (NFC) (PR #202577)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 04:02:07 PDT 2026
================
@@ -7219,27 +7219,24 @@ Value *llvm::simplifyBinaryIntrinsic(Intrinsic::ID IID, Type *ReturnType,
return nullptr;
}
-static Value *simplifyIntrinsic(CallBase *Call, Value *Callee,
- ArrayRef<Value *> Args,
- const SimplifyQuery &Q) {
- // Operand bundles should not be in Args.
- assert(Call->arg_size() == Args.size());
+Value *llvm::simplifyIntrinsic(Intrinsic::ID IID, Type *ReturnType,
+ ArrayRef<Value *> Args, FastMathFlags FMF,
+ const SimplifyQuery &Q,
+ fp::ExceptionBehavior ExBehavior,
+ RoundingMode Rounding,
+ ConstantRange VScaleRange) {
unsigned NumOperands = Args.size();
- Function *F = cast<Function>(Callee);
- Intrinsic::ID IID = F->getIntrinsicID();
-
if (IID != Intrinsic::not_intrinsic && intrinsicPropagatesPoison(IID) &&
any_of(Args, IsaPred<PoisonValue>))
- return PoisonValue::get(F->getReturnType());
+ return PoisonValue::get(ReturnType);
+
// Most of the intrinsics with no operands have some kind of side effect.
// Don't simplify.
if (!NumOperands) {
switch (IID) {
case Intrinsic::vscale: {
- Type *RetTy = F->getReturnType();
- ConstantRange CR = getVScaleRange(Call->getFunction(), 64);
- if (const APInt *C = CR.getSingleElement())
- return ConstantInt::get(RetTy, C->getZExtValue());
+ if (const APInt *C = VScaleRange.getSingleElement())
----------------
nikic wrote:
I think I'd prefer taking a context Function instead of VScaleRange in particular. This also makes sure we'll have things like the denormal mode available.
https://github.com/llvm/llvm-project/pull/202577
More information about the llvm-commits
mailing list