-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[NVPTX] Add auto-upgrade rules for fabs.{f,d,ftz.f} #136150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlexMaclean
merged 1 commit into
llvm:main
from
AlexMaclean:dev/amaclean/upstream/fixup-fabs-upgrade
Apr 17, 2025
Merged
[NVPTX] Add auto-upgrade rules for fabs.{f,d,ftz.f} #136150
AlexMaclean
merged 1 commit into
llvm:main
from
AlexMaclean:dev/amaclean/upstream/fixup-fabs-upgrade
Apr 17, 2025
+22
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-backend-nvptx Author: Alex MacLean (AlexMaclean) ChangesThese auto-upgrade rules are required after these intrinsics were removed in #135644 Full diff: https://github.com/llvm/llvm-project/pull/136150.diff 2 Files Affected:
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 7a91da5f9f7eb..2e17b8ce5eb7b 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -1287,6 +1287,9 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
// nvvm.abs.{i,ii}
Expand =
Name == "i" || Name == "ll" || Name == "bf16" || Name == "bf16x2";
+ else if (Name == "fabs.f" || Name == "fabs.ftz.f" || Name == "fabs.d")
+ // nvvm.fabs.{f,ftz.f,d}
+ Expand = true;
else if (Name == "clz.ll" || Name == "popc.ll" || Name == "h2f" ||
Name == "swap.lo.hi.b64")
Expand = true;
@@ -2318,6 +2321,10 @@ static Value *upgradeNVVMIntrinsicCall(StringRef Name, CallBase *CI,
Value *Arg = Builder.CreateBitCast(CI->getArgOperand(0), Ty);
Value *Abs = Builder.CreateUnaryIntrinsic(Intrinsic::nvvm_fabs, Arg);
Rep = Builder.CreateBitCast(Abs, CI->getType());
+ } else if (Name == "fabs.f" || Name == "fabs.ftz.f" || Name == "fabs.d") {
+ Intrinsic::ID IID = (Name == "fabs.ftz.f") ? Intrinsic::nvvm_fabs_ftz
+ : Intrinsic::nvvm_fabs;
+ Rep = Builder.CreateUnaryIntrinsic(IID, CI->getArgOperand(0));
} else if (Name.starts_with("atomic.load.add.f32.p") ||
Name.starts_with("atomic.load.add.f64.p")) {
Value *Ptr = CI->getArgOperand(0);
diff --git a/llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll b/llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
index 74b9640df6977..a3ddc62dd34e9 100644
--- a/llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
+++ b/llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
@@ -13,6 +13,10 @@ declare float @llvm.nvvm.h2f(i16)
declare i32 @llvm.nvvm.abs.i(i32)
declare i64 @llvm.nvvm.abs.ll(i64)
+declare float @llvm.nvvm.fabs.f(float)
+declare float @llvm.nvvm.fabs.ftz.f(float)
+declare double @llvm.nvvm.fabs.d(double)
+
declare i16 @llvm.nvvm.max.s(i16, i16)
declare i32 @llvm.nvvm.max.i(i32, i32)
declare i64 @llvm.nvvm.max.ll(i64, i64)
@@ -97,6 +101,17 @@ define void @abs(i32 %a, i64 %b) {
ret void
}
+; CHECK-LABEL: @fabs
+define void @fabs(float %a, double %b) {
+; CHECK: call float @llvm.nvvm.fabs.f32(float %a)
+; CHECK: call float @llvm.nvvm.fabs.ftz.f32(float %a)
+; CHECK: call double @llvm.nvvm.fabs.f64(double %b)
+ %r1 = call float @llvm.nvvm.fabs.f(float %a)
+ %r2 = call float @llvm.nvvm.fabs.ftz.f(float %a)
+ %r3 = call double @llvm.nvvm.fabs.d(double %b)
+ ret void
+}
+
; CHECK-LABEL: @min_max
define void @min_max(i16 %a1, i16 %a2, i32 %b1, i32 %b2, i64 %c1, i64 %c2) {
; CHECK: [[maxs:%[a-zA-Z0-9.]+]] = icmp sge i16 %a1, %a2
|
Will this fix the builedbot #135644? |
Yes. |
Artem-B
approved these changes
Apr 17, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
These auto-upgrade rules are required after these intrinsics were removed in llvm#135644
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
These auto-upgrade rules are required after these intrinsics were removed in llvm#135644
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These auto-upgrade rules are required after these intrinsics were removed in #135644