xref: /llvm-project/llvm/test/CodeGen/X86/strict-fadd-combines.ll (revision 8ccf1c117b0dc08f7e9c24fe98f45ebe32e95cd1)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X86
3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X64
4
5define float @fneg_strict_fadd_to_strict_fsub(float %x, float %y) nounwind strictfp {
6; X86-LABEL: fneg_strict_fadd_to_strict_fsub:
7; X86:       # %bb.0:
8; X86-NEXT:    pushl %eax
9; X86-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
10; X86-NEXT:    subss {{[0-9]+}}(%esp), %xmm0
11; X86-NEXT:    movss %xmm0, (%esp)
12; X86-NEXT:    flds (%esp)
13; X86-NEXT:    wait
14; X86-NEXT:    popl %eax
15; X86-NEXT:    retl
16;
17; X64-LABEL: fneg_strict_fadd_to_strict_fsub:
18; X64:       # %bb.0:
19; X64-NEXT:    subss %xmm1, %xmm0
20; X64-NEXT:    retq
21  %neg = fneg float %y
22  %add = call float @llvm.experimental.constrained.fadd.f32(float %x, float %neg, metadata!"round.dynamic", metadata!"fpexcept.strict")
23  ret float %add
24}
25
26define float @fneg_strict_fadd_to_strict_fsub_2(float %x, float %y) nounwind strictfp {
27; X86-LABEL: fneg_strict_fadd_to_strict_fsub_2:
28; X86:       # %bb.0:
29; X86-NEXT:    pushl %eax
30; X86-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
31; X86-NEXT:    subss {{[0-9]+}}(%esp), %xmm0
32; X86-NEXT:    movss %xmm0, (%esp)
33; X86-NEXT:    flds (%esp)
34; X86-NEXT:    wait
35; X86-NEXT:    popl %eax
36; X86-NEXT:    retl
37;
38; X64-LABEL: fneg_strict_fadd_to_strict_fsub_2:
39; X64:       # %bb.0:
40; X64-NEXT:    subss %xmm1, %xmm0
41; X64-NEXT:    retq
42  %neg = fneg float %y
43  %add = call float @llvm.experimental.constrained.fadd.f32(float %neg, float %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
44  ret float %add
45}
46
47define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind strictfp {
48; X86-LABEL: fneg_strict_fadd_to_strict_fsub_d:
49; X86:       # %bb.0:
50; X86-NEXT:    pushl %ebp
51; X86-NEXT:    movl %esp, %ebp
52; X86-NEXT:    andl $-8, %esp
53; X86-NEXT:    subl $8, %esp
54; X86-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
55; X86-NEXT:    subsd 16(%ebp), %xmm0
56; X86-NEXT:    movsd %xmm0, (%esp)
57; X86-NEXT:    fldl (%esp)
58; X86-NEXT:    wait
59; X86-NEXT:    movl %ebp, %esp
60; X86-NEXT:    popl %ebp
61; X86-NEXT:    retl
62;
63; X64-LABEL: fneg_strict_fadd_to_strict_fsub_d:
64; X64:       # %bb.0:
65; X64-NEXT:    subsd %xmm1, %xmm0
66; X64-NEXT:    retq
67  %neg = fneg double %y
68  %add = call double @llvm.experimental.constrained.fadd.f64(double %x, double %neg, metadata!"round.dynamic", metadata!"fpexcept.strict")
69  ret double %add
70}
71
72define double @fneg_strict_fadd_to_strict_fsub_2d(double %x, double %y) nounwind strictfp {
73; X86-LABEL: fneg_strict_fadd_to_strict_fsub_2d:
74; X86:       # %bb.0:
75; X86-NEXT:    pushl %ebp
76; X86-NEXT:    movl %esp, %ebp
77; X86-NEXT:    andl $-8, %esp
78; X86-NEXT:    subl $8, %esp
79; X86-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
80; X86-NEXT:    subsd 16(%ebp), %xmm0
81; X86-NEXT:    movsd %xmm0, (%esp)
82; X86-NEXT:    fldl (%esp)
83; X86-NEXT:    wait
84; X86-NEXT:    movl %ebp, %esp
85; X86-NEXT:    popl %ebp
86; X86-NEXT:    retl
87;
88; X64-LABEL: fneg_strict_fadd_to_strict_fsub_2d:
89; X64:       # %bb.0:
90; X64-NEXT:    subsd %xmm1, %xmm0
91; X64-NEXT:    retq
92  %neg = fneg double %y
93  %add = call double @llvm.experimental.constrained.fadd.f64(double %neg, double %x, metadata!"round.dynamic", metadata!"fpexcept.strict")
94  ret double %add
95}
96
97
98declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata)
99declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
100