Debian Codegraph @

gcc/testsuite/gcc.target/riscv/bf16_arithmetic.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-march=rv32i -mabi=ilp32 -O" { target { rv32 } } } */
3 /* { dg-options "-march=rv64i -mabi=lp64 -O" { target { rv64 } } } */
4
5 /* 1) bf -> sf (call __extendbfsf2) */
6 /* 2) sf1 [+|-|*|/] sf2 (call __[add|sub|mul|div]sf3) */
7 /* 3) sf -> bf (call __truncsfbf2) */
8 extern __bf16 bf;
9 extern __bf16 bf1;
10 extern __bf16 bf2;
11
12 void bf_add_bf () { bf = bf1 + bf2; }
13
14 void bf_sub_bf () { bf = bf1 - bf2; }
15
16 void bf_mul_bf () { bf = bf1 * bf2; }
17
18 void bf_div_bf () { bf = bf1 / bf2; }
19
20 void bf_add_const () { bf = bf1 + 3.14f; }
21
22 void const_sub_bf () { bf = 3.14f - bf2; }
23
24 void bf_mul_const () { bf = bf1 * 3.14f; }
25
26 void const_div_bf () { bf = 3.14f / bf2; }
27
28 void bf_inc () { ++bf; }
29
30 void bf_dec () { --bf; }
31
32 /* { dg-final { scan-assembler-times "call\t__extendbfsf2" 16 } } */
33 /* { dg-final { scan-assembler-times "call\t__truncsfbf2" 10 } } */
34 /* { dg-final { scan-assembler-times "call\t__addsf3" 3 } } */
35 /* { dg-final { scan-assembler-times "call\t__subsf3" 3 } } */
36 /* { dg-final { scan-assembler-times "call\t__mulsf3" 2 } } */
37 /* { dg-final { scan-assembler-times "call\t__divsf3" 2 } } */
38
39 /* { dg-final { scan-assembler-not "call\t__addbf3" } } */
40 /* { dg-final { scan-assembler-not "call\t__subbf3" } } */
41 /* { dg-final { scan-assembler-not "call\t__mulbf3" } } */
42 /* { dg-final { scan-assembler-not "call\t__divbf3" } } */