Skip to content

Commit 8ccf1c1

Browse files
authored
[FPEnv][X86] Correct strictfp tests. (#87791)
Correct strictfp tests to follow the rules documented in the LangRef: https://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics These tests needed the strictfp attribute added to some function definitions. FP wait instructions now appear as a result. Test changes verified with D146845.
1 parent 40327a6 commit 8ccf1c1

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

llvm/test/CodeGen/X86/strict-fadd-combines.ll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X86
33
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X64
44

5-
define float @fneg_strict_fadd_to_strict_fsub(float %x, float %y) nounwind {
5+
define float @fneg_strict_fadd_to_strict_fsub(float %x, float %y) nounwind strictfp {
66
; X86-LABEL: fneg_strict_fadd_to_strict_fsub:
77
; X86: # %bb.0:
88
; X86-NEXT: pushl %eax
99
; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
1010
; X86-NEXT: subss {{[0-9]+}}(%esp), %xmm0
1111
; X86-NEXT: movss %xmm0, (%esp)
1212
; X86-NEXT: flds (%esp)
13+
; X86-NEXT: wait
1314
; X86-NEXT: popl %eax
1415
; X86-NEXT: retl
1516
;
@@ -22,14 +23,15 @@ define float @fneg_strict_fadd_to_strict_fsub(float %x, float %y) nounwind {
2223
ret float %add
2324
}
2425

25-
define float @fneg_strict_fadd_to_strict_fsub_2(float %x, float %y) nounwind {
26+
define float @fneg_strict_fadd_to_strict_fsub_2(float %x, float %y) nounwind strictfp {
2627
; X86-LABEL: fneg_strict_fadd_to_strict_fsub_2:
2728
; X86: # %bb.0:
2829
; X86-NEXT: pushl %eax
2930
; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
3031
; X86-NEXT: subss {{[0-9]+}}(%esp), %xmm0
3132
; X86-NEXT: movss %xmm0, (%esp)
3233
; X86-NEXT: flds (%esp)
34+
; X86-NEXT: wait
3335
; X86-NEXT: popl %eax
3436
; X86-NEXT: retl
3537
;
@@ -42,7 +44,7 @@ define float @fneg_strict_fadd_to_strict_fsub_2(float %x, float %y) nounwind {
4244
ret float %add
4345
}
4446

45-
define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind {
47+
define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind strictfp {
4648
; X86-LABEL: fneg_strict_fadd_to_strict_fsub_d:
4749
; X86: # %bb.0:
4850
; X86-NEXT: pushl %ebp
@@ -53,6 +55,7 @@ define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind
5355
; X86-NEXT: subsd 16(%ebp), %xmm0
5456
; X86-NEXT: movsd %xmm0, (%esp)
5557
; X86-NEXT: fldl (%esp)
58+
; X86-NEXT: wait
5659
; X86-NEXT: movl %ebp, %esp
5760
; X86-NEXT: popl %ebp
5861
; X86-NEXT: retl
@@ -66,7 +69,7 @@ define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind
6669
ret double %add
6770
}
6871

69-
define double @fneg_strict_fadd_to_strict_fsub_2d(double %x, double %y) nounwind {
72+
define double @fneg_strict_fadd_to_strict_fsub_2d(double %x, double %y) nounwind strictfp {
7073
; X86-LABEL: fneg_strict_fadd_to_strict_fsub_2d:
7174
; X86: # %bb.0:
7275
; X86-NEXT: pushl %ebp
@@ -77,6 +80,7 @@ define double @fneg_strict_fadd_to_strict_fsub_2d(double %x, double %y) nounwind
7780
; X86-NEXT: subsd 16(%ebp), %xmm0
7881
; X86-NEXT: movsd %xmm0, (%esp)
7982
; X86-NEXT: fldl (%esp)
83+
; X86-NEXT: wait
8084
; X86-NEXT: movl %ebp, %esp
8185
; X86-NEXT: popl %ebp
8286
; X86-NEXT: retl

llvm/test/CodeGen/X86/strict-fsub-combines.ll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X64
44

55
; FIXME: Missing fsub(x,fneg(y)) -> fadd(x,y) fold
6-
define float @fneg_strict_fsub_to_strict_fadd(float %x, float %y) nounwind {
6+
define float @fneg_strict_fsub_to_strict_fadd(float %x, float %y) nounwind strictfp {
77
; X86-LABEL: fneg_strict_fsub_to_strict_fadd:
88
; X86: # %bb.0:
99
; X86-NEXT: pushl %eax
@@ -13,6 +13,7 @@ define float @fneg_strict_fsub_to_strict_fadd(float %x, float %y) nounwind {
1313
; X86-NEXT: subss %xmm1, %xmm0
1414
; X86-NEXT: movss %xmm0, (%esp)
1515
; X86-NEXT: flds (%esp)
16+
; X86-NEXT: wait
1617
; X86-NEXT: popl %eax
1718
; X86-NEXT: retl
1819
;
@@ -27,7 +28,7 @@ define float @fneg_strict_fsub_to_strict_fadd(float %x, float %y) nounwind {
2728
}
2829

2930
; FIXME: Missing fsub(x,fneg(y)) -> fadd(x,y) fold
30-
define double @fneg_strict_fsub_to_strict_fadd_d(double %x, double %y) nounwind {
31+
define double @fneg_strict_fsub_to_strict_fadd_d(double %x, double %y) nounwind strictfp {
3132
; X86-LABEL: fneg_strict_fsub_to_strict_fadd_d:
3233
; X86: # %bb.0:
3334
; X86-NEXT: pushl %ebp
@@ -40,6 +41,7 @@ define double @fneg_strict_fsub_to_strict_fadd_d(double %x, double %y) nounwind
4041
; X86-NEXT: subsd %xmm1, %xmm0
4142
; X86-NEXT: movsd %xmm0, (%esp)
4243
; X86-NEXT: fldl (%esp)
44+
; X86-NEXT: wait
4345
; X86-NEXT: movl %ebp, %esp
4446
; X86-NEXT: popl %ebp
4547
; X86-NEXT: retl
@@ -55,7 +57,7 @@ define double @fneg_strict_fsub_to_strict_fadd_d(double %x, double %y) nounwind
5557
}
5658

5759
; FIXME: Missing fneg(fsub(x,y)) -> fsub(y,x) fold
58-
define float @strict_fsub_fneg_to_strict_fsub(float %x, float %y) nounwind {
60+
define float @strict_fsub_fneg_to_strict_fsub(float %x, float %y) nounwind strictfp {
5961
; X86-LABEL: strict_fsub_fneg_to_strict_fsub:
6062
; X86: # %bb.0:
6163
; X86-NEXT: pushl %eax
@@ -64,6 +66,7 @@ define float @strict_fsub_fneg_to_strict_fsub(float %x, float %y) nounwind {
6466
; X86-NEXT: xorps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
6567
; X86-NEXT: movss %xmm0, (%esp)
6668
; X86-NEXT: flds (%esp)
69+
; X86-NEXT: wait
6770
; X86-NEXT: popl %eax
6871
; X86-NEXT: retl
6972
;
@@ -78,7 +81,7 @@ define float @strict_fsub_fneg_to_strict_fsub(float %x, float %y) nounwind {
7881
}
7982

8083
; FIXME: Missing fneg(fsub(x,y)) -> fsub(y,x) fold
81-
define double @strict_fsub_fneg_to_strict_fsub_d(double %x, double %y) nounwind {
84+
define double @strict_fsub_fneg_to_strict_fsub_d(double %x, double %y) nounwind strictfp {
8285
; X86-LABEL: strict_fsub_fneg_to_strict_fsub_d:
8386
; X86: # %bb.0:
8487
; X86-NEXT: pushl %ebp
@@ -90,6 +93,7 @@ define double @strict_fsub_fneg_to_strict_fsub_d(double %x, double %y) nounwind
9093
; X86-NEXT: xorpd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
9194
; X86-NEXT: movlpd %xmm0, (%esp)
9295
; X86-NEXT: fldl (%esp)
96+
; X86-NEXT: wait
9397
; X86-NEXT: movl %ebp, %esp
9498
; X86-NEXT: popl %ebp
9599
; X86-NEXT: retl

0 commit comments

Comments
 (0)