[llvm] e309667 - [AutoUpgrade] Simplify vclz upgrade (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 07:30:07 PST 2023


Author: Nikita Popov
Date: 2023-12-04T16:30:00+01:00
New Revision: e309667769c8f7d6f5616c226ee43a19dcee8bf3

URL: https://github.com/llvm/llvm-project/commit/e309667769c8f7d6f5616c226ee43a19dcee8bf3
DIFF: https://github.com/llvm/llvm-project/commit/e309667769c8f7d6f5616c226ee43a19dcee8bf3.diff

LOG: [AutoUpgrade] Simplify vclz upgrade (NFC)

We can use Intrinsic::getDeclaration() here, we just have to pass
the correct arguments. This function accepts only the mangled types,
not all argument types.

Added: 
    

Modified: 
    llvm/lib/IR/AutoUpgrade.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 7a40f24661caf..67ee7b7d97e9a 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -782,16 +782,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
       return true;
     }
     if (Name.starts_with("arm.neon.vclz")) {
-      Type* args[2] = {
-        F->arg_begin()->getType(),
-        Type::getInt1Ty(F->getContext())
-      };
-      // Can't use Intrinsic::getDeclaration here as it adds a ".i1" to
-      // the end of the name. Change name from llvm.arm.neon.vclz.* to
-      //  llvm.ctlz.*
-      FunctionType* fType = FunctionType::get(F->getReturnType(), args, false);
-      NewFn = Function::Create(fType, F->getLinkage(), F->getAddressSpace(),
-                               "llvm.ctlz." + Name.substr(14), F->getParent());
+      NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::ctlz,
+                                        F->arg_begin()->getType());
       return true;
     }
     if (Name.starts_with("arm.neon.vcnt")) {


        


More information about the llvm-commits mailing list