[llvm] [NVPTX] Fix lowering of fabs and fneg (PR #219089)

Lewis Crawford via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 05:29:57 PDT 2026


================
@@ -67,8 +67,8 @@ define float @fcopysign_f_h(float %a, half %b) {
 ; CHECK-EMPTY:
 ; CHECK-NEXT:  // %bb.0:
 ; CHECK-NEXT:    ld.param.b32 %r1, [fcopysign_f_h_param_0];
-; CHECK-NEXT:    abs.f32 %r2, %r1;
-; CHECK-NEXT:    neg.f32 %r3, %r2;
+; CHECK-NEXT:    and.b32 %r2, %r1, 2147483647;
----------------
LewisCrawford wrote:

We can probably generate better sequences than the `sign(x) ? fneg(fabs(y)) : fabs(y)` path here for these mixed-precision copysigns (e.g. using `bfi` ). Might be worth a follow-up patch at some point.

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


More information about the llvm-commits mailing list