| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-march=rv32i_zfbfmin -mabi=ilp32f -O" { target { rv32 } } } */ |
| 3 |
/* { dg-options "-march=rv64i_zfbfmin -mabi=lp64f -O" { target { rv64 } } } */ |
| 4 |
|
| 5 |
|
| 6 |
/* 1) float -> BF16 |
| 7 |
* hf -> bf == hf -> sf -> bf fcvt.h.s + fcvt.bf16.s |
| 8 |
* sf -> bf == sf -> bf fcvt.bf16.s |
| 9 |
* df -> bf == df -> sf -> bf __truncdfsf2 + fcvt.bf16.s |
| 10 |
* tf -> bf == tf -> sf -> bf __trunctfsf2 + fcvt.bf16.s |
| 11 |
*/ |
| 12 |
|
| 13 |
/* 2) BF16 -> float |
| 14 |
* bf -> hf == bf -> sf -> hf fcvt.s.bf16 + fcvt.s.h |
| 15 |
* bf -> sf == bf -> sf fcvt.s.bf16 |
| 16 |
* bf -> df == bf -> sf -> df fcvt.s.bf16 + __extendsfdf2 |
| 17 |
* bf -> tf == bf -> sf -> tf fcvt.s.bf16 + __extendsftf2 |
| 18 |
*/ |
| 19 |
|
| 20 |
extern __bf16 bf; |
| 21 |
extern _Float16 hf; |
| 22 |
extern float sf; |
| 23 |
extern double df; |
| 24 |
extern long double tf; |
| 25 |
|
| 26 |
void hf_to_bf () { bf = hf; } |
| 27 |
void bf_to_hf () { hf = bf; } |
| 28 |
|
| 29 |
void sf_to_bf () { bf = sf; } |
| 30 |
void bf_to_sf () { sf = bf; } |
| 31 |
|
| 32 |
void df_to_bf () { bf = df; } |
| 33 |
void bf_to_df () { df = bf; } |
| 34 |
|
| 35 |
void tf_to_bf () { bf = tf; } |
| 36 |
void bf_to_tf () { tf = bf; } |
| 37 |
|
| 38 |
/* { dg-final { scan-assembler-times "fcvt.bf16.s" 4 } } */ |
| 39 |
/* { dg-final { scan-assembler-times "fcvt.s.bf16" 4 } } */ |
| 40 |
/* { dg-final { scan-assembler-times "fcvt.h.s" 1 } } */ |
| 41 |
/* { dg-final { scan-assembler-times "fcvt.s.h" 1 } } */ |
| 42 |
/* { dg-final { scan-assembler-times "call\t__truncdfsf2" 1 } } */ |
| 43 |
/* { dg-final { scan-assembler-times "call\t__trunctfsf2" 1 } } */ |
| 44 |
/* { dg-final { scan-assembler-times "call\t__extendsfdf2" 1 } } */ |
| 45 |
/* { dg-final { scan-assembler-times "call\t__extendsftf2" 1 } } */ |