[llvm] [Transforms] Let amdgcn take advantage of sin(-x) --> -sin(x) (PR #79700)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 09:23:27 PDT 2024
================
@@ -1023,6 +1023,47 @@ define float @cos_fabs_unary_fneg_f32(float %x) {
ret float %cos
}
+
+; --------------------------------------------------------------------
+; llvm.amdgcn.sin
+; --------------------------------------------------------------------
+declare float @llvm.amdgcn.sin.f32(float) nounwind readnone
+
+define float @sin_fneg_f32(float %x) {
+; CHECK-LABEL: @sin_fneg_f32(
+; CHECK-NEXT: [[X_FNEG:%.*]] = fsub float 0.000000e+00, [[X:%.*]]
+; CHECK-NEXT: [[SIN:%.*]] = call float @llvm.amdgcn.sin.f32(float [[X_FNEG]])
+; CHECK-NEXT: ret float [[SIN]]
+;
+ %x.fneg = fsub float 0.0, %x
----------------
arsenm wrote:
```suggestion
%x.fneg = fneg float %x
```
https://github.com/llvm/llvm-project/pull/79700
More information about the llvm-commits
mailing list