[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 Feb 1 01:47:37 PST 2024


================
@@ -1023,6 +1023,50 @@ define float @cos_fabs_unary_fneg_f32(float %x) {
   ret float %cos
 }
 
+
+; --------------------------------------------------------------------
+; llvm.amdgcn.sin
+; --------------------------------------------------------------------
+declare float @llvm.amdgcn.sin.f32(float) nounwind readnone
+
+; CHECK-NEXT: ret float %cos
+define float @sin_fneg_f32(float %x) {
+; CHECK-LABEL: @sin_fneg_f32(
+; CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.amdgcn.sin.f32(float [[X:%.*]])
+; CHECK-NEXT:    [[SIN:%.*]] = fneg float [[TMP1]]
+; CHECK-NEXT:    ret float [[SIN]]
+;
+  %x.fneg = fsub float -0.0, %x
----------------
arsenm wrote:

What do you mean other test? I don't see another test? fneg is still preferable to magic fsub 

https://github.com/llvm/llvm-project/pull/79700


More information about the llvm-commits mailing list