-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[Transforms] Let amdgcn take advantage of sin(-x) --> -sin(x) #79700
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-llvm-transforms Author: AtariDreams (AtariDreams) ChangesWe do it for amdgcn_cos, and we should do it for amdgcn_sin as well. Full diff: https://github.com/llvm/llvm-project/pull/79700.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index a647be2d26c7613..ce54d49323dc6eb 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2497,11 +2497,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
}
break;
}
- case Intrinsic::sin: {
+ case Intrinsic::sin:
+ case Intrinsic::amdgcn_sin: {
Value *X;
if (match(II->getArgOperand(0), m_OneUse(m_FNeg(m_Value(X))))) {
// sin(-x) --> -sin(x)
- Value *NewSin = Builder.CreateUnaryIntrinsic(Intrinsic::sin, X, II);
+ Value *NewSin = Builder.CreateUnaryIntrinsic(IID, X, II);
Instruction *FNeg = UnaryOperator::CreateFNeg(NewSin);
FNeg->copyFastMathFlags(II);
return FNeg;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test
a367853
to
73bd4b1
Compare
Fixed! @arsenm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the opposite of what we want for codegen, but I believe we undo this already
9e450fd
to
9e265ba
Compare
3c8d208
to
33c5ddf
Compare
Out of curiosity what's the purpose of doing this? From one of the tests attached It just looks like we are moving |
We do it for amdgcn_cos, and we should do it for amdgcn_sin as well.
Why close this? |
We do it for amdgcn_cos, and we should do it for amdgcn_sin as well.