File: cvt16-2.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (171 lines) | stat: -rw-r--r-- 5,581 bytes parent folder | download | duplicates (9)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=-avx512fp16 | FileCheck %s -check-prefix=LIBCALL
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512fp16 | FileCheck %s -check-prefix=FP16

define void @test1(float %src, ptr %dest) {
; LIBCALL-LABEL: test1:
; LIBCALL:       # %bb.0:
; LIBCALL-NEXT:    pushq %rbx
; LIBCALL-NEXT:    .cfi_def_cfa_offset 16
; LIBCALL-NEXT:    .cfi_offset %rbx, -16
; LIBCALL-NEXT:    movq %rdi, %rbx
; LIBCALL-NEXT:    callq __truncsfhf2@PLT
; LIBCALL-NEXT:    pextrw $0, %xmm0, %eax
; LIBCALL-NEXT:    movw %ax, (%rbx)
; LIBCALL-NEXT:    popq %rbx
; LIBCALL-NEXT:    .cfi_def_cfa_offset 8
; LIBCALL-NEXT:    retq
;
; FP16-LABEL: test1:
; FP16:       # %bb.0:
; FP16-NEXT:    vcvtss2sh %xmm0, %xmm0, %xmm0
; FP16-NEXT:    vmovsh %xmm0, (%rdi)
; FP16-NEXT:    retq
  %1 = tail call i16 @llvm.convert.to.fp16.f32(float %src)
  store i16 %1, ptr %dest, align 2
  ret void
}

define float @test2(ptr nocapture %src) {
; LIBCALL-LABEL: test2:
; LIBCALL:       # %bb.0:
; LIBCALL-NEXT:    pinsrw $0, (%rdi), %xmm0
; LIBCALL-NEXT:    jmp __extendhfsf2@PLT # TAILCALL
;
; FP16-LABEL: test2:
; FP16:       # %bb.0:
; FP16-NEXT:    vmovsh (%rdi), %xmm0
; FP16-NEXT:    vcvtsh2ss %xmm0, %xmm0, %xmm0
; FP16-NEXT:    retq
  %1 = load i16, ptr %src, align 2
  %2 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
  ret float %2
}

define float @test3(float %src) nounwind uwtable readnone {
; LIBCALL-LABEL: test3:
; LIBCALL:       # %bb.0:
; LIBCALL-NEXT:    pushq %rax
; LIBCALL-NEXT:    .cfi_def_cfa_offset 16
; LIBCALL-NEXT:    callq __truncsfhf2@PLT
; LIBCALL-NEXT:    popq %rax
; LIBCALL-NEXT:    .cfi_def_cfa_offset 8
; LIBCALL-NEXT:    jmp __extendhfsf2@PLT # TAILCALL
;
; FP16-LABEL: test3:
; FP16:       # %bb.0:
; FP16-NEXT:    vcvtss2sh %xmm0, %xmm0, %xmm0
; FP16-NEXT:    vcvtsh2ss %xmm0, %xmm0, %xmm0
; FP16-NEXT:    retq
  %1 = tail call i16 @llvm.convert.to.fp16.f32(float %src)
  %2 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
  ret float %2
}

; FIXME: Should it be __extendhfdf2?
define double @test4(ptr nocapture %src) {
; LIBCALL-LABEL: test4:
; LIBCALL:       # %bb.0:
; LIBCALL-NEXT:    pushq %rax
; LIBCALL-NEXT:    .cfi_def_cfa_offset 16
; LIBCALL-NEXT:    pinsrw $0, (%rdi), %xmm0
; LIBCALL-NEXT:    callq __extendhfsf2@PLT
; LIBCALL-NEXT:    cvtss2sd %xmm0, %xmm0
; LIBCALL-NEXT:    popq %rax
; LIBCALL-NEXT:    .cfi_def_cfa_offset 8
; LIBCALL-NEXT:    retq
;
; FP16-LABEL: test4:
; FP16:       # %bb.0:
; FP16-NEXT:    vmovsh (%rdi), %xmm0
; FP16-NEXT:    vcvtsh2sd %xmm0, %xmm0, %xmm0
; FP16-NEXT:    retq
  %1 = load i16, ptr %src, align 2
  %2 = tail call double @llvm.convert.from.fp16.f64(i16 %1)
  ret double %2
}

define i16 @test5(double %src) {
; LIBCALL-LABEL: test5:
; LIBCALL:       # %bb.0:
; LIBCALL-NEXT:    pushq %rax
; LIBCALL-NEXT:    .cfi_def_cfa_offset 16
; LIBCALL-NEXT:    callq __truncdfhf2@PLT
; LIBCALL-NEXT:    pextrw $0, %xmm0, %eax
; LIBCALL-NEXT:    # kill: def $ax killed $ax killed $eax
; LIBCALL-NEXT:    popq %rcx
; LIBCALL-NEXT:    .cfi_def_cfa_offset 8
; LIBCALL-NEXT:    retq
;
; FP16-LABEL: test5:
; FP16:       # %bb.0:
; FP16-NEXT:    vcvtsd2sh %xmm0, %xmm0, %xmm0
; FP16-NEXT:    vmovw %xmm0, %eax
; FP16-NEXT:    # kill: def $ax killed $ax killed $eax
; FP16-NEXT:    retq
  %val = tail call i16 @llvm.convert.to.fp16.f64(double %src)
  ret i16 %val
}

; FIXME: Should it be __extendhfxf2?
define x86_fp80 @test6(ptr nocapture %src) {
; LIBCALL-LABEL: test6:
; LIBCALL:       # %bb.0:
; LIBCALL-NEXT:    pushq %rax
; LIBCALL-NEXT:    .cfi_def_cfa_offset 16
; LIBCALL-NEXT:    pinsrw $0, (%rdi), %xmm0
; LIBCALL-NEXT:    callq __extendhfxf2@PLT
; LIBCALL-NEXT:    popq %rax
; LIBCALL-NEXT:    .cfi_def_cfa_offset 8
; LIBCALL-NEXT:    retq
;
; FP16-LABEL: test6:
; FP16:       # %bb.0:
; FP16-NEXT:    pushq %rax
; FP16-NEXT:    .cfi_def_cfa_offset 16
; FP16-NEXT:    vmovsh (%rdi), %xmm0
; FP16-NEXT:    callq __extendhfxf2@PLT
; FP16-NEXT:    popq %rax
; FP16-NEXT:    .cfi_def_cfa_offset 8
; FP16-NEXT:    retq
  %1 = load i16, ptr %src, align 2
  %2 = tail call x86_fp80 @llvm.convert.from.fp16.f80(i16 %1)
  ret x86_fp80 %2
}

define i16 @test7(x86_fp80 %src) {
; LIBCALL-LABEL: test7:
; LIBCALL:       # %bb.0:
; LIBCALL-NEXT:    subq $24, %rsp
; LIBCALL-NEXT:    .cfi_def_cfa_offset 32
; LIBCALL-NEXT:    fldt {{[0-9]+}}(%rsp)
; LIBCALL-NEXT:    fstpt (%rsp)
; LIBCALL-NEXT:    callq __truncxfhf2@PLT
; LIBCALL-NEXT:    pextrw $0, %xmm0, %eax
; LIBCALL-NEXT:    # kill: def $ax killed $ax killed $eax
; LIBCALL-NEXT:    addq $24, %rsp
; LIBCALL-NEXT:    .cfi_def_cfa_offset 8
; LIBCALL-NEXT:    retq
;
; FP16-LABEL: test7:
; FP16:       # %bb.0:
; FP16-NEXT:    subq $24, %rsp
; FP16-NEXT:    .cfi_def_cfa_offset 32
; FP16-NEXT:    fldt {{[0-9]+}}(%rsp)
; FP16-NEXT:    fstpt (%rsp)
; FP16-NEXT:    callq __truncxfhf2@PLT
; FP16-NEXT:    vmovw %xmm0, %eax
; FP16-NEXT:    # kill: def $ax killed $ax killed $eax
; FP16-NEXT:    addq $24, %rsp
; FP16-NEXT:    .cfi_def_cfa_offset 8
; FP16-NEXT:    retq
  %val = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %src)
  ret i16 %val
}

declare float @llvm.convert.from.fp16.f32(i16) nounwind readnone
declare i16 @llvm.convert.to.fp16.f32(float) nounwind readnone
declare double @llvm.convert.from.fp16.f64(i16) nounwind readnone
declare i16 @llvm.convert.to.fp16.f64(double) nounwind readnone
declare x86_fp80 @llvm.convert.from.fp16.f80(i16) nounwind readnone
declare i16 @llvm.convert.to.fp16.f80(x86_fp80) nounwind readnone