blob: 14944fab7d00dca122ae16993e2c8d3478a5c53c [file] [log] [blame]
Simon Pilgrima328ee62021-07-10 15:08:34 +01001; 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
Drew Wock0ec098e2020-08-26 15:17:17 -04004
Kevin P. Neal8ccf1c12024-04-08 10:14:02 -04005define float @fneg_strict_fadd_to_strict_fsub(float %x, float %y) nounwind strictfp {
Simon Pilgrima328ee62021-07-10 15:08:34 +01006; 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)
Kevin P. Neal8ccf1c12024-04-08 10:14:02 -040013; X86-NEXT: wait
Simon Pilgrima328ee62021-07-10 15:08:34 +010014; 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
Drew Wock0ec098e2020-08-26 15:17:17 -040021 %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
Kevin P. Neal8ccf1c12024-04-08 10:14:02 -040026define float @fneg_strict_fadd_to_strict_fsub_2(float %x, float %y) nounwind strictfp {
Simon Pilgrima328ee62021-07-10 15:08:34 +010027; 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)
Kevin P. Neal8ccf1c12024-04-08 10:14:02 -040034; X86-NEXT: wait
Simon Pilgrima328ee62021-07-10 15:08:34 +010035; 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
Drew Wock0ec098e2020-08-26 15:17:17 -040042 %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
Kevin P. Neal8ccf1c12024-04-08 10:14:02 -040047define double @fneg_strict_fadd_to_strict_fsub_d(double %x, double %y) nounwind strictfp {
Simon Pilgrima328ee62021-07-10 15:08:34 +010048; 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)
Kevin P. Neal8ccf1c12024-04-08 10:14:02 -040058; X86-NEXT: wait
Simon Pilgrima328ee62021-07-10 15:08:34 +010059; 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
Drew Wock0ec098e2020-08-26 15:17:17 -040067 %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
Kevin P. Neal8ccf1c12024-04-08 10:14:02 -040072define double @fneg_strict_fadd_to_strict_fsub_2d(double %x, double %y) nounwind strictfp {
Simon Pilgrima328ee62021-07-10 15:08:34 +010073; 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)
Kevin P. Neal8ccf1c12024-04-08 10:14:02 -040083; X86-NEXT: wait
Simon Pilgrima328ee62021-07-10 15:08:34 +010084; 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
Drew Wock0ec098e2020-08-26 15:17:17 -040092 %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)