Skip to content

Commit 4a9bbb4

Browse files
committed
Remove UnsafeFPMath in visitFMUL
1 parent 69ac706 commit 4a9bbb4

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17935,7 +17935,7 @@ SDValue DAGCombiner::visitFMUL(SDNode *N) {
1793517935
if (SDValue NewSel = foldBinOpIntoSelect(N))
1793617936
return NewSel;
1793717937

17938-
if (Options.UnsafeFPMath || Flags.hasAllowReassociation()) {
17938+
if (Flags.hasAllowReassociation()) {
1793917939
// fmul (fmul X, C1), C2 -> fmul X, C1 * C2
1794017940
if (DAG.isConstantFPBuildVectorOrConstantFP(N1) &&
1794117941
N0.getOpcode() == ISD::FMUL) {

llvm/test/CodeGen/AMDGPU/llvm.sin.ll

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
; GFX9-NOT: v_fract_f32
1717
; GCN: v_sin_f32
1818
; GCN-NOT: v_sin_f32
19-
define amdgpu_kernel void @sin_f32(ptr addrspace(1) %out, float %x) #1 {
19+
define amdgpu_kernel void @sin_f32(ptr addrspace(1) %out, float %x) {
2020
%sin = call float @llvm.sin.f32(float %x)
2121
store float %sin, ptr addrspace(1) %out
2222
ret void
@@ -29,7 +29,7 @@ define amdgpu_kernel void @sin_f32(ptr addrspace(1) %out, float %x) #1 {
2929
; GFX9-NOT: v_fract_f32
3030
; GCN: v_sin_f32
3131
; GCN-NOT: v_sin_f32
32-
define amdgpu_kernel void @safe_sin_3x_f32(ptr addrspace(1) %out, float %x) #1 {
32+
define amdgpu_kernel void @safe_sin_3x_f32(ptr addrspace(1) %out, float %x) {
3333
%y = fmul float 3.0, %x
3434
%sin = call float @llvm.sin.f32(float %y)
3535
store float %sin, ptr addrspace(1) %out
@@ -44,9 +44,9 @@ define amdgpu_kernel void @safe_sin_3x_f32(ptr addrspace(1) %out, float %x) #1 {
4444
; GFX9-NOT: v_fract_f32
4545
; GCN: v_sin_f32
4646
; GCN-NOT: v_sin_f32
47-
define amdgpu_kernel void @unsafe_sin_3x_f32(ptr addrspace(1) %out, float %x) #2 {
48-
%y = fmul float 3.0, %x
49-
%sin = call float @llvm.sin.f32(float %y)
47+
define amdgpu_kernel void @unsafe_sin_3x_f32(ptr addrspace(1) %out, float %x) {
48+
%y = fmul reassoc float 3.0, %x
49+
%sin = call reassoc float @llvm.sin.f32(float %y)
5050
store float %sin, ptr addrspace(1) %out
5151
ret void
5252
}
@@ -59,7 +59,7 @@ define amdgpu_kernel void @unsafe_sin_3x_f32(ptr addrspace(1) %out, float %x) #2
5959
; GFX9-NOT: v_fract_f32
6060
; GCN: v_sin_f32
6161
; GCN-NOT: v_sin_f32
62-
define amdgpu_kernel void @fmf_sin_3x_f32(ptr addrspace(1) %out, float %x) #1 {
62+
define amdgpu_kernel void @fmf_sin_3x_f32(ptr addrspace(1) %out, float %x) {
6363
%y = fmul reassoc float 3.0, %x
6464
%sin = call reassoc float @llvm.sin.f32(float %y)
6565
store float %sin, ptr addrspace(1) %out
@@ -73,7 +73,7 @@ define amdgpu_kernel void @fmf_sin_3x_f32(ptr addrspace(1) %out, float %x) #1 {
7373
; GFX9-NOT: v_fract_f32
7474
; GCN: v_sin_f32
7575
; GCN-NOT: v_sin_f32
76-
define amdgpu_kernel void @safe_sin_2x_f32(ptr addrspace(1) %out, float %x) #1 {
76+
define amdgpu_kernel void @safe_sin_2x_f32(ptr addrspace(1) %out, float %x) {
7777
%y = fmul float 2.0, %x
7878
%sin = call float @llvm.sin.f32(float %y)
7979
store float %sin, ptr addrspace(1) %out
@@ -88,9 +88,9 @@ define amdgpu_kernel void @safe_sin_2x_f32(ptr addrspace(1) %out, float %x) #1 {
8888
; GFX9-NOT: v_fract_f32
8989
; GCN: v_sin_f32
9090
; GCN-NOT: v_sin_f32
91-
define amdgpu_kernel void @unsafe_sin_2x_f32(ptr addrspace(1) %out, float %x) #2 {
92-
%y = fmul float 2.0, %x
93-
%sin = call float @llvm.sin.f32(float %y)
91+
define amdgpu_kernel void @unsafe_sin_2x_f32(ptr addrspace(1) %out, float %x) {
92+
%y = fmul reassoc float 2.0, %x
93+
%sin = call reassoc float @llvm.sin.f32(float %y)
9494
store float %sin, ptr addrspace(1) %out
9595
ret void
9696
}
@@ -103,7 +103,7 @@ define amdgpu_kernel void @unsafe_sin_2x_f32(ptr addrspace(1) %out, float %x) #2
103103
; GFX9-NOT: v_fract_f32
104104
; GCN: v_sin_f32
105105
; GCN-NOT: v_sin_f32
106-
define amdgpu_kernel void @fmf_sin_2x_f32(ptr addrspace(1) %out, float %x) #1 {
106+
define amdgpu_kernel void @fmf_sin_2x_f32(ptr addrspace(1) %out, float %x) {
107107
%y = fmul reassoc float 2.0, %x
108108
%sin = call reassoc float @llvm.sin.f32(float %y)
109109
store float %sin, ptr addrspace(1) %out
@@ -117,7 +117,7 @@ define amdgpu_kernel void @fmf_sin_2x_f32(ptr addrspace(1) %out, float %x) #1 {
117117
; GFX9-NOT: v_fract_f32
118118
; GCN: v_sin_f32
119119
; GCN-NOT: v_sin_f32
120-
define amdgpu_kernel void @safe_sin_cancel_f32(ptr addrspace(1) %out, float %x) #1 {
120+
define amdgpu_kernel void @safe_sin_cancel_f32(ptr addrspace(1) %out, float %x) {
121121
%y = fmul float 0x401921FB60000000, %x
122122
%sin = call float @llvm.sin.f32(float %y)
123123
store float %sin, ptr addrspace(1) %out
@@ -131,9 +131,9 @@ define amdgpu_kernel void @safe_sin_cancel_f32(ptr addrspace(1) %out, float %x)
131131
; GFX9-NOT: v_fract_f32
132132
; GCN: v_sin_f32
133133
; GCN-NOT: v_sin_f32
134-
define amdgpu_kernel void @unsafe_sin_cancel_f32(ptr addrspace(1) %out, float %x) #2 {
135-
%y = fmul float 0x401921FB60000000, %x
136-
%sin = call float @llvm.sin.f32(float %y)
134+
define amdgpu_kernel void @unsafe_sin_cancel_f32(ptr addrspace(1) %out, float %x) {
135+
%y = fmul reassoc float 0x401921FB60000000, %x
136+
%sin = call reassoc float @llvm.sin.f32(float %y)
137137
store float %sin, ptr addrspace(1) %out
138138
ret void
139139
}
@@ -145,7 +145,7 @@ define amdgpu_kernel void @unsafe_sin_cancel_f32(ptr addrspace(1) %out, float %x
145145
; GFX9-NOT: v_fract_f32
146146
; GCN: v_sin_f32
147147
; GCN-NOT: v_sin_f32
148-
define amdgpu_kernel void @fmf_sin_cancel_f32(ptr addrspace(1) %out, float %x) #1 {
148+
define amdgpu_kernel void @fmf_sin_cancel_f32(ptr addrspace(1) %out, float %x) {
149149
%y = fmul reassoc float 0x401921FB60000000, %x
150150
%sin = call reassoc float @llvm.sin.f32(float %y)
151151
store float %sin, ptr addrspace(1) %out
@@ -164,7 +164,7 @@ define amdgpu_kernel void @fmf_sin_cancel_f32(ptr addrspace(1) %out, float %x) #
164164
; GCN: v_sin_f32
165165
; GCN: v_sin_f32
166166
; GCN-NOT: v_sin_f32
167-
define amdgpu_kernel void @sin_v4f32(ptr addrspace(1) %out, <4 x float> %vx) #1 {
167+
define amdgpu_kernel void @sin_v4f32(ptr addrspace(1) %out, <4 x float> %vx) {
168168
%sin = call <4 x float> @llvm.sin.v4f32( <4 x float> %vx)
169169
store <4 x float> %sin, ptr addrspace(1) %out
170170
ret void
@@ -174,5 +174,3 @@ declare float @llvm.sin.f32(float) #0
174174
declare <4 x float> @llvm.sin.v4f32(<4 x float>) #0
175175

176176
attributes #0 = { nounwind readnone }
177-
attributes #1 = { nounwind "unsafe-fp-math"="false" }
178-
attributes #2 = { nounwind "unsafe-fp-math"="true" }

0 commit comments

Comments
 (0)