Skip to content

Commit

Permalink
Add vfcvt for half <-> single
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 13, 2023
1 parent 67f47f1 commit 49ebab3
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 6 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ TODO List:

### vfrstp.b/h

### vfcvt.h.s

### vffint.s.l

### vffint.w.d
Expand All @@ -24,10 +22,6 @@ TODO List:

### vfrstpi.b/h

### vfcvtl.s.h

### vfcvth.s.h

### vffint.s.w/wu/d.l/d.lu

### vffintl.d.w
Expand Down
7 changes: 7 additions & 0 deletions code/vfcvt_h_s.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
for (int i = 0; i < 8; i++) {
if (i < 4) {
dst.fp16[i] = b.fp32[i];
} else {
dst.fp16[i] = a.fp32[i - 4];
}
}
3 changes: 3 additions & 0 deletions code/vfcvth_s_h.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
for (int i = 0; i < 4; i++) {
dst.fp32[i] = a.fp16[4 + i];
}
3 changes: 3 additions & 0 deletions code/vfcvtl_s_h.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
for (int i = 0; i < 4; i++) {
dst.fp32[i] = a.fp16[i];
}
64 changes: 64 additions & 0 deletions docs/lsx/float_conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,70 @@ Convert double precision floating point elements in `a` and `b` to double precis
{% include('vfcvt_s_d.h') %}
```

## __m128 __lsx_vfcvth_s_h (__m128i a)

### Synopsis

```c++
__m128 __lsx_vfcvth_s_h (__m128i a)
#include <lsxintrin.h>
Instruction: vfcvth.s.h vr, vr
CPU Flags: LSX
```
### Description
Convert half precision floating point elements in higher half of `a` to single precision.
### Operation
```c++
{% include('vfcvth_s_h.h') %}
```

## __m128d __lsx_vfcvtl_s_h (__m128i a)

### Synopsis

```c++
__m128d __lsx_vfcvtl_s_h (__m128i a)
#include <lsxintrin.h>
Instruction: vfcvtl.s.h vr, vr
CPU Flags: LSX
```
### Description
Convert half precision floating point elements in lower half of `a` to single precision.
### Operation
```c++
{% include('vfcvtl_s_h.h') %}
```


## __m128i __lsx_vfcvt_h_s (__m128 a, __m128 b)

### Synopsis

```c++
__m128i __lsx_vfcvt_h_s (__m128, __m128 b)
#include <lsxintrin.h>
Instruction: vfcvt.h.s vr, vr, vr
CPU Flags: LSX
```
### Description
Convert single precision floating point elements in `a` and `b` to half precision.
### Operation
```c++
{% include('vfcvt_h_s.h') %}
```

{{ vftint_l_s('', 'l') }}
{{ vftint_l_s('', 'h') }}
{{ vftint_l_s('rm', 'l') }}
Expand Down

0 comments on commit 49ebab3

Please sign in to comment.