[llvm] [InstSimplify] Expose simplifyIntrinsic (NFC) (PR #202577)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 08:23:28 PDT 2026


================
@@ -7219,27 +7219,25 @@ 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, Function *CxtF) {
   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);
+      ConstantRange CR =
+          CxtF ? getVScaleRange(CxtF, 64) : ConstantRange::getFull(64);
----------------
nikic wrote:

I think we can just `if (!CxtF) return nullptr;` here?

https://github.com/llvm/llvm-project/pull/202577


More information about the llvm-commits mailing list