-
Notifications
You must be signed in to change notification settings - Fork 14.3k
AMDGPU: Make fma_legacy intrinsic propagate poison #131063
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
Merged
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
This was referenced Mar 13, 2025
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-backend-amdgpu Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/131063.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
index ba4e6e530fe56..86f33f33d1fc7 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -1281,6 +1281,11 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
Value *Op1 = II.getArgOperand(1);
Value *Op2 = II.getArgOperand(2);
+ for (Value *Src : {Op0, Op1, Op2}) {
+ if (isa<PoisonValue>(Src))
+ return IC.replaceInstUsesWith(II, Src);
+ }
+
// The legacy behaviour is that multiplying +/-0.0 by anything, even NaN or
// infinity, gives +0.0.
// TODO: Move to InstSimplify?
diff --git a/llvm/test/Transforms/InstCombine/AMDGPU/fma_legacy.ll b/llvm/test/Transforms/InstCombine/AMDGPU/fma_legacy.ll
index 72bffe62fbb14..b2f851d6d56ed 100644
--- a/llvm/test/Transforms/InstCombine/AMDGPU/fma_legacy.ll
+++ b/llvm/test/Transforms/InstCombine/AMDGPU/fma_legacy.ll
@@ -105,6 +105,30 @@ define float @test_finite_assumed(float %x, float %y, float %z) {
ret float %call
}
+define float @test_poison_x_y(float %x, float %y) {
+; CHECK-LABEL: @test_poison_x_y(
+; CHECK-NEXT: ret float poison
+;
+ %call = call float @llvm.amdgcn.fma.legacy(float poison, float %x, float %y)
+ ret float %call
+}
+
+define float @test_x_poison_y(float %x, float %y) {
+; CHECK-LABEL: @test_x_poison_y(
+; CHECK-NEXT: ret float poison
+;
+ %call = call float @llvm.amdgcn.fma.legacy(float %x, float poison, float %y)
+ ret float %call
+}
+
+define float @test_x_y_poison_y(float %x, float %y) {
+; CHECK-LABEL: @test_x_y_poison_y(
+; CHECK-NEXT: ret float poison
+;
+ %call = call float @llvm.amdgcn.fma.legacy(float %x, float %y, float poison)
+ ret float %call
+}
+
declare float @llvm.amdgcn.fma.legacy(float, float, float)
declare float @llvm.fabs.f32(float)
declare void @llvm.assume(i1 noundef)
|
Pierre-vh
approved these changes
Mar 13, 2025
5f4a37d
to
cd3c53b
Compare
6c1b91a
to
45508d8
Compare
cd3c53b
to
ebc436a
Compare
Base automatically changed from
users/arsenm/amdgpu/propagate-poison-fmul-legacy
to
main
March 14, 2025 04:39
45508d8
to
91e5d67
Compare
frederik-h
pushed a commit
to frederik-h/llvm-project
that referenced
this pull request
Mar 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backend:AMDGPU
llvm:instcombine
Covers the InstCombine, InstSimplify and AggressiveInstCombine passes
llvm:transforms
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.
No description provided.