-
Notifications
You must be signed in to change notification settings - Fork 14.3k
AMDGPU: Make fmul_legacy intrinsic propagate poison #131062
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-backend-amdgpu Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/131062.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
index 083fa2a730fff..ba4e6e530fe56 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -1255,6 +1255,11 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
Value *Op0 = II.getArgOperand(0);
Value *Op1 = II.getArgOperand(1);
+ for (Value *Src : {Op0, Op1}) {
+ 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/fmul_legacy.ll b/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll
index d58470d6b12ad..899b611b929d1 100644
--- a/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll
+++ b/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll
@@ -75,6 +75,22 @@ define float @test_finite_assumed(float %x, float %y) {
ret float %call
}
+define float @test_poison_var(float %x) {
+; CHECK-LABEL: @test_poison_var(
+; CHECK-NEXT: ret float poison
+;
+ %call = call float @llvm.amdgcn.fmul.legacy(float poison, float %x)
+ ret float %call
+}
+
+define float @test_var_poison(float %x) {
+; CHECK-LABEL: @test_var_poison(
+; CHECK-NEXT: ret float poison
+;
+ %call = call float @llvm.amdgcn.fmul.legacy(float %x, float poison)
+ ret float %call
+}
+
declare float @llvm.amdgcn.fmul.legacy(float, float)
declare float @llvm.fabs.f32(float)
declare void @llvm.assume(i1 noundef)
|
@llvm/pr-subscribers-llvm-transforms Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/131062.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
index 083fa2a730fff..ba4e6e530fe56 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -1255,6 +1255,11 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
Value *Op0 = II.getArgOperand(0);
Value *Op1 = II.getArgOperand(1);
+ for (Value *Src : {Op0, Op1}) {
+ 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/fmul_legacy.ll b/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll
index d58470d6b12ad..899b611b929d1 100644
--- a/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll
+++ b/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll
@@ -75,6 +75,22 @@ define float @test_finite_assumed(float %x, float %y) {
ret float %call
}
+define float @test_poison_var(float %x) {
+; CHECK-LABEL: @test_poison_var(
+; CHECK-NEXT: ret float poison
+;
+ %call = call float @llvm.amdgcn.fmul.legacy(float poison, float %x)
+ ret float %call
+}
+
+define float @test_var_poison(float %x) {
+; CHECK-LABEL: @test_var_poison(
+; CHECK-NEXT: ret float poison
+;
+ %call = call float @llvm.amdgcn.fmul.legacy(float %x, float poison)
+ ret float %call
+}
+
declare float @llvm.amdgcn.fmul.legacy(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
3d22d1c
to
be3d513
Compare
909bb78
to
3d94386
Compare
Base automatically changed from
users/arsenm/amdgpu/propagate-poison-ballot
to
main
March 14, 2025 04:36
cd3c53b
to
ebc436a
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.