Skip to content

Commit 4967bc1

Browse files
authored
[DAGCombiner] Remove NoSignedZerosFPMath in visitFNEG (#162052)
Remove the `NoSignedZerosFPMath` use in `visitFNEG`. Now the only use of `NoSignedZerosFPMath` is in `foldFPToIntToFP`, but adding fast-math flags support for `uitofp` may introduce breaking changes.
1 parent 71586a6 commit 4967bc1

File tree

3 files changed

+1405
-2702
lines changed

3 files changed

+1405
-2702
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19319,9 +19319,8 @@ SDValue DAGCombiner::visitFNEG(SDNode *N) {
1931919319
// FIXME: This is duplicated in getNegatibleCost, but getNegatibleCost doesn't
1932019320
// know it was called from a context with a nsz flag if the input fsub does
1932119321
// not.
19322-
if (N0.getOpcode() == ISD::FSUB &&
19323-
(DAG.getTarget().Options.NoSignedZerosFPMath ||
19324-
N->getFlags().hasNoSignedZeros()) && N0.hasOneUse()) {
19322+
if (N0.getOpcode() == ISD::FSUB && N->getFlags().hasNoSignedZeros() &&
19323+
N0.hasOneUse()) {
1932519324
return DAG.getNode(ISD::FSUB, SDLoc(N), VT, N0.getOperand(1),
1932619325
N0.getOperand(0));
1932719326
}

llvm/test/CodeGen/AMDGPU/fsub.ll

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -92,43 +92,11 @@ define amdgpu_kernel void @v_fneg_fsub_nsz_f32(ptr addrspace(1) %out, ptr addrsp
9292
ret void
9393
}
9494

95-
; FUNC-LABEL: {{^}}v_fneg_fsub_nsz_attribute_f32:
96-
; SI: v_sub_f32_e32 [[SUB:v[0-9]+]], {{v[0-9]+}}, {{v[0-9]+}}
97-
; SI-NOT: xor
98-
define amdgpu_kernel void @v_fneg_fsub_nsz_attribute_f32(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
99-
%b_ptr = getelementptr float, ptr addrspace(1) %in, i32 1
100-
%a = load float, ptr addrspace(1) %in, align 4
101-
%b = load float, ptr addrspace(1) %b_ptr, align 4
102-
%result = fsub float %a, %b
103-
%neg.result = fsub float -0.0, %result
104-
store float %neg.result, ptr addrspace(1) %out, align 4
105-
ret void
106-
}
107-
108-
; For some reason the attribute has a string "true" or "false", so
109-
; make sure it is disabled and the fneg is not folded if it is not
110-
; "true".
111-
; FUNC-LABEL: {{^}}v_fneg_fsub_nsz_false_attribute_f32:
112-
; SI: v_sub_f32_e32 [[SUB:v[0-9]+]], {{v[0-9]+}}, {{v[0-9]+}}
113-
; SI: v_xor_b32_e32 v{{[0-9]+}}, 0x80000000, [[SUB]]
114-
define amdgpu_kernel void @v_fneg_fsub_nsz_false_attribute_f32(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
115-
%b_ptr = getelementptr float, ptr addrspace(1) %in, i32 1
116-
%a = load float, ptr addrspace(1) %in, align 4
117-
%b = load float, ptr addrspace(1) %b_ptr, align 4
118-
%result = fsub float %a, %b
119-
%neg.result = fsub float -0.0, %result
120-
store float %neg.result, ptr addrspace(1) %out, align 4
121-
ret void
122-
}
123-
124-
; FUNC-LABEL: {{^}}v_fsub_0_nsz_attribute_f32:
95+
; FUNC-LABEL: {{^}}v_fsub_0_nsz_flag_f32:
12596
; SI-NOT: v_sub
126-
define amdgpu_kernel void @v_fsub_0_nsz_attribute_f32(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
97+
define amdgpu_kernel void @v_fsub_0_nsz_flag_f32(ptr addrspace(1) %out, ptr addrspace(1) %in) {
12798
%a = load float, ptr addrspace(1) %in, align 4
128-
%result = fsub float %a, 0.0
99+
%result = fsub nsz float %a, 0.0
129100
store float %result, ptr addrspace(1) %out, align 4
130101
ret void
131102
}
132-
133-
attributes #0 = { nounwind "no-signed-zeros-fp-math"="true" }
134-
attributes #1 = { nounwind "no-signed-zeros-fp-math"="false" }

0 commit comments

Comments
 (0)