Skip to content

Commit

Permalink
[FPEnv][X86] Correct strictfp tests. (llvm#87791)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kpneal authored Apr 8, 2024
1 parent 40327a6 commit 8ccf1c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions llvm/test/CodeGen/X86/strict-fadd-combines.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X86
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X64

define float @fneg_strict_fadd_to_strict_fsub(float %x, float %y) nounwind {
define float @fneg_strict_fadd_to_strict_fsub(float %x, float %y) nounwind strictfp {
; X86-LABEL: fneg_strict_fadd_to_strict_fsub:
; X86: # %bb.0:
; X86-NEXT: pushl %eax
; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
; X86-NEXT: subss {{[0-9]+}}(%esp), %xmm0
; X86-NEXT: movss %xmm0, (%esp)
; X86-NEXT: flds (%esp)
; X86-NEXT: wait
; X86-NEXT: popl %eax
; X86-NEXT: retl
;
Expand All @@ -22,14 +23,15 @@ define float @fneg_strict_fadd_to_strict_fsub(float %x, float %y) nounwind {
ret float %add
}

define float @fneg_strict_fadd_to_strict_fsub_2(float %x, float %y) nounwind {
define float @fneg_strict_fadd_to_strict_fsub_2(float %x, float %y) nounwind strictfp {
; X86-LABEL: fneg_strict_fadd_to_strict_fsub_2:
; X86: # %bb.0:
; X86-NEXT: pushl %eax
; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
; X86-NEXT: subss {{[0-9]+}}(%esp), %xmm0
; X86-NEXT: movss %xmm0, (%esp)
; X86-NEXT: flds (%esp)
; X86-NEXT: wait
; X86-NEXT: popl %eax
; X86-NEXT: retl
;
Expand All @@ -42,7 +44,7 @@ define float @fneg_strict_fadd_to_strict_fsub_2(float %x, float %y) nounwind {
ret float %add
}

define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind {
define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind strictfp {
; X86-LABEL: fneg_strict_fadd_to_strict_fsub_d:
; X86: # %bb.0:
; X86-NEXT: pushl %ebp
Expand All @@ -53,6 +55,7 @@ define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind
; X86-NEXT: subsd 16(%ebp), %xmm0
; X86-NEXT: movsd %xmm0, (%esp)
; X86-NEXT: fldl (%esp)
; X86-NEXT: wait
; X86-NEXT: movl %ebp, %esp
; X86-NEXT: popl %ebp
; X86-NEXT: retl
Expand All @@ -66,7 +69,7 @@ define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind
ret double %add
}

define double @fneg_strict_fadd_to_strict_fsub_2d(double %x, double %y) nounwind {
define double @fneg_strict_fadd_to_strict_fsub_2d(double %x, double %y) nounwind strictfp {
; X86-LABEL: fneg_strict_fadd_to_strict_fsub_2d:
; X86: # %bb.0:
; X86-NEXT: pushl %ebp
Expand All @@ -77,6 +80,7 @@ define double @fneg_strict_fadd_to_strict_fsub_2d(double %x, double %y) nounwind
; X86-NEXT: subsd 16(%ebp), %xmm0
; X86-NEXT: movsd %xmm0, (%esp)
; X86-NEXT: fldl (%esp)
; X86-NEXT: wait
; X86-NEXT: movl %ebp, %esp
; X86-NEXT: popl %ebp
; X86-NEXT: retl
Expand Down
12 changes: 8 additions & 4 deletions llvm/test/CodeGen/X86/strict-fsub-combines.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X64

; FIXME: Missing fsub(x,fneg(y)) -> fadd(x,y) fold
define float @fneg_strict_fsub_to_strict_fadd(float %x, float %y) nounwind {
define float @fneg_strict_fsub_to_strict_fadd(float %x, float %y) nounwind strictfp {
; X86-LABEL: fneg_strict_fsub_to_strict_fadd:
; X86: # %bb.0:
; X86-NEXT: pushl %eax
Expand All @@ -13,6 +13,7 @@ define float @fneg_strict_fsub_to_strict_fadd(float %x, float %y) nounwind {
; X86-NEXT: subss %xmm1, %xmm0
; X86-NEXT: movss %xmm0, (%esp)
; X86-NEXT: flds (%esp)
; X86-NEXT: wait
; X86-NEXT: popl %eax
; X86-NEXT: retl
;
Expand All @@ -27,7 +28,7 @@ define float @fneg_strict_fsub_to_strict_fadd(float %x, float %y) nounwind {
}

; FIXME: Missing fsub(x,fneg(y)) -> fadd(x,y) fold
define double @fneg_strict_fsub_to_strict_fadd_d(double %x, double %y) nounwind {
define double @fneg_strict_fsub_to_strict_fadd_d(double %x, double %y) nounwind strictfp {
; X86-LABEL: fneg_strict_fsub_to_strict_fadd_d:
; X86: # %bb.0:
; X86-NEXT: pushl %ebp
Expand All @@ -40,6 +41,7 @@ define double @fneg_strict_fsub_to_strict_fadd_d(double %x, double %y) nounwind
; X86-NEXT: subsd %xmm1, %xmm0
; X86-NEXT: movsd %xmm0, (%esp)
; X86-NEXT: fldl (%esp)
; X86-NEXT: wait
; X86-NEXT: movl %ebp, %esp
; X86-NEXT: popl %ebp
; X86-NEXT: retl
Expand All @@ -55,7 +57,7 @@ define double @fneg_strict_fsub_to_strict_fadd_d(double %x, double %y) nounwind
}

; FIXME: Missing fneg(fsub(x,y)) -> fsub(y,x) fold
define float @strict_fsub_fneg_to_strict_fsub(float %x, float %y) nounwind {
define float @strict_fsub_fneg_to_strict_fsub(float %x, float %y) nounwind strictfp {
; X86-LABEL: strict_fsub_fneg_to_strict_fsub:
; X86: # %bb.0:
; X86-NEXT: pushl %eax
Expand All @@ -64,6 +66,7 @@ define float @strict_fsub_fneg_to_strict_fsub(float %x, float %y) nounwind {
; X86-NEXT: xorps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
; X86-NEXT: movss %xmm0, (%esp)
; X86-NEXT: flds (%esp)
; X86-NEXT: wait
; X86-NEXT: popl %eax
; X86-NEXT: retl
;
Expand All @@ -78,7 +81,7 @@ define float @strict_fsub_fneg_to_strict_fsub(float %x, float %y) nounwind {
}

; FIXME: Missing fneg(fsub(x,y)) -> fsub(y,x) fold
define double @strict_fsub_fneg_to_strict_fsub_d(double %x, double %y) nounwind {
define double @strict_fsub_fneg_to_strict_fsub_d(double %x, double %y) nounwind strictfp {
; X86-LABEL: strict_fsub_fneg_to_strict_fsub_d:
; X86: # %bb.0:
; X86-NEXT: pushl %ebp
Expand All @@ -90,6 +93,7 @@ define double @strict_fsub_fneg_to_strict_fsub_d(double %x, double %y) nounwind
; X86-NEXT: xorpd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
; X86-NEXT: movlpd %xmm0, (%esp)
; X86-NEXT: fldl (%esp)
; X86-NEXT: wait
; X86-NEXT: movl %ebp, %esp
; X86-NEXT: popl %ebp
; X86-NEXT: retl
Expand Down

0 comments on commit 8ccf1c1

Please sign in to comment.