aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/X86/strict-fadd-combines.ll
blob: 14944fab7d00dca122ae16993e2c8d3478a5c53c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; 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 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
;
; X64-LABEL: fneg_strict_fadd_to_strict_fsub:
; X64:       # %bb.0:
; X64-NEXT:    subss %xmm1, %xmm0
; X64-NEXT:    retq
  %neg = fneg float %y
  %add = call float @llvm.experimental.constrained.fadd.f32(float %x, float %neg, metadata!"round.dynamic", metadata!"fpexcept.strict")
  ret float %add
}

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
;
; X64-LABEL: fneg_strict_fadd_to_strict_fsub_2:
; X64:       # %bb.0:
; X64-NEXT:    subss %xmm1, %xmm0
; X64-NEXT:    retq
  %neg = fneg float %y
  %add = call float @llvm.experimental.constrained.fadd.f32(float %neg, float %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
  ret float %add
}

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
; X86-NEXT:    movl %esp, %ebp
; X86-NEXT:    andl $-8, %esp
; X86-NEXT:    subl $8, %esp
; X86-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
; 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
;
; X64-LABEL: fneg_strict_fadd_to_strict_fsub_d:
; X64:       # %bb.0:
; X64-NEXT:    subsd %xmm1, %xmm0
; X64-NEXT:    retq
  %neg = fneg double %y
  %add = call double @llvm.experimental.constrained.fadd.f64(double %x, double %neg, metadata!"round.dynamic", metadata!"fpexcept.strict")
  ret double %add
}

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
; X86-NEXT:    movl %esp, %ebp
; X86-NEXT:    andl $-8, %esp
; X86-NEXT:    subl $8, %esp
; X86-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
; 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
;
; X64-LABEL: fneg_strict_fadd_to_strict_fsub_2d:
; X64:       # %bb.0:
; X64-NEXT:    subsd %xmm1, %xmm0
; X64-NEXT:    retq
  %neg = fneg double %y
  %add = call double @llvm.experimental.constrained.fadd.f64(double %neg, double %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
  ret double %add
}


declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata)
declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)