Skip to content

Commit 644de6a

Browse files
committed
Revert "[NVPTX] designate fabs and fneg as free (#121513)"
This reverts commit 45d4698. NVPTX fabs & fneg are incompatible with LLVM's semantics as LLVM guarantees the payload of NaNs to stay the same while PTX mangles NaNs. The bad patterns are still in the NVPTX backend and should probably be removed, since this change only exposed the bad behavior.
1 parent 21ba7ae commit 644de6a

File tree

3 files changed

+4
-41
lines changed

3 files changed

+4
-41
lines changed

llvm/lib/Target/NVPTX/NVPTXISelLowering.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,6 @@ class NVPTXTargetLowering : public TargetLowering {
261261
return true;
262262
}
263263

264-
bool isFAbsFree(EVT VT) const override { return true; }
265-
bool isFNegFree(EVT VT) const override { return true; }
266-
267264
private:
268265
const NVPTXSubtarget &STI; // cache the subtarget here
269266
SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT) const;

llvm/test/CodeGen/NVPTX/bf16x2-instructions.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ define <2 x bfloat> @test_fneg(<2 x bfloat> %a) #0 {
182182
; CHECK-NEXT: .reg .b32 %r<3>;
183183
; CHECK-EMPTY:
184184
; CHECK-NEXT: // %bb.0:
185-
; CHECK-NEXT: ld.param.b32 %r1, [test_fneg_param_0];
186-
; CHECK-NEXT: neg.bf16x2 %r2, %r1;
185+
; CHECK-NEXT: ld.param.u32 %r1, [test_fneg_param_0];
186+
; CHECK-NEXT: xor.b32 %r2, %r1, -2147450880;
187187
; CHECK-NEXT: st.param.b32 [func_retval0], %r2;
188188
; CHECK-NEXT: ret;
189189
%r = fneg <2 x bfloat> %a
@@ -532,8 +532,8 @@ define <2 x bfloat> @test_fabs(<2 x bfloat> %a) #0 {
532532
; CHECK-NEXT: .reg .b32 %r<3>;
533533
; CHECK-EMPTY:
534534
; CHECK-NEXT: // %bb.0:
535-
; CHECK-NEXT: ld.param.b32 %r1, [test_fabs_param_0];
536-
; CHECK-NEXT: abs.bf16x2 %r2, %r1;
535+
; CHECK-NEXT: ld.param.u32 %r1, [test_fabs_param_0];
536+
; CHECK-NEXT: and.b32 %r2, %r1, 2147450879;
537537
; CHECK-NEXT: st.param.b32 [func_retval0], %r2;
538538
; CHECK-NEXT: ret;
539539
%r = call <2 x bfloat> @llvm.fabs.f16(<2 x bfloat> %a)

llvm/test/CodeGen/NVPTX/fabs-fneg-free.ll

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)