[llvm] [llvm][NFC] Autoupdater AMD intrinsic detection (PR #73331)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 24 11:50:28 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Nathan Sidwell (urnathan)
<details>
<summary>Changes</summary>
Here's a refactor of the amd autoupdater, using prefix stripping and commonizing the replacement fndecl creation.
---
Full diff: https://github.com/llvm/llvm-project/pull/73331.diff
1 Files Affected:
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+19-18)
``````````diff
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 63c4b2c71299900..4a9b8e10b43e3f3 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -945,29 +945,30 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
return true;
if (Name.consume_front("amdgcn.")) {
- if (Name == "alignbit") {
- // Target specific intrinsic became redundant
- NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::fshr,
- {F->getReturnType()});
- return true;
- }
- if (Name.starts_with("atomic.inc") || Name.starts_with("atomic.dec")) {
- // This was replaced with atomicrmw uinc_wrap and udec_wrap, so there's no
- // new declaration.
- NewFn = nullptr;
+ Intrinsic::ID ID = StringSwitch<Intrinsic::ID>(Name)
+ .Case("alignbit", Intrinsic::fshr)
+ .StartsWith("ldexp.", Intrinsic::ldexp)
+ .Default(Intrinsic::not_intrinsic);
+ if (ID != Intrinsic::not_intrinsic) {
+ // Some target-specific intrinsics became redundant.
+ SmallVector<Type *, 2> Tys;
+ Tys.push_back(F->getReturnType());
+ if (ID == Intrinsic::ldexp)
+ Tys.push_back(F->getArg(1)->getType());
+ NewFn = Intrinsic::getDeclaration(F->getParent(), ID, Tys);
return true;
}
- if (Name.starts_with("ldexp.")) {
- // Target specific intrinsic became redundant
- NewFn = Intrinsic::getDeclaration(
- F->getParent(), Intrinsic::ldexp,
- {F->getReturnType(), F->getArg(1)->getType()});
- return true;
- }
+ if (Name.consume_front("atomic."))
+ if (Name.starts_with("inc") || Name.starts_with("dec")) {
+ // These were replaced with atomicrmw uinc_wrap and udec_wrap, so
+ // there's no new declaration.
+ NewFn = nullptr;
+ return true;
+ }
+ break; // No other 'amdgcn.*'
}
-
break;
}
case 'c': {
``````````
</details>
https://github.com/llvm/llvm-project/pull/73331
More information about the llvm-commits
mailing list