https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118103
--- Comment #3 from Li Pan <pan2.li at intel dot com> ---
Interesting the test_example in a separate function other than main will have
the frm restore insn, but there will be no such frm in main function.
62 │ test_exampe:
63 │ frrm a2
64 │ fsrmi 2
65 │ lui a3,%hi(a)
66 │ addi a3,a3,%lo(a)
67 │ lui a5,%hi(b)
68 │ vsetivli zero,4,e16,m1,ta,ma
69 │ vle16.v v1,0(a3)
70 │ addi a5,a5,%lo(b)
71 │ vfnmadd.vv v1,v1,v1
72 │ fsrm a2 // Has FRM
73 │ vfmsub.vv v1,v1,v1
74 │ vse16.v v1,0(a5)
75 │ ret
76 │ .size test_exampe, .-test_exampe
77 │ .section .text.startup,"ax",@progbits
78 │ .align 1
79 │ .globl main
80 │ .type main, @function
81 │ main:
82 │ addi sp,sp,-16
83 │ sd ra,8(sp)
84 │ call initialize
85 │ fsrmi 2
86 │ lui a3,%hi(a)
87 │ addi a3,a3,%lo(a)
88 │ lui a5,%hi(b)
89 │ vsetivli zero,4,e16,m1,ta,ma
90 │ vle16.v v1,0(a3)
91 │ addi a5,a5,%lo(b)
92 │ vfnmadd.vv v1,v1,v1 // No FRM
93 │ vfmsub.vv v1,v1,v1
94 │ vse16.v v1,0(a5)
95 │ call print_result
96 │ ld ra,8(sp)
97 │ li a0,0
98 │ addi sp,sp,16
99 │ jr ra
52 │ void test_exampe () {
53 │ int avl = dataLen;
54 │ float16_t* ptr_a = a; float16_t* ptr_b = b;
55 │ size_t vl = __riscv_vsetvl_e16m1(avl);
56 │ vfloat16m1_t va = __riscv_vle16_v_f16m1(ptr_a, vl);
57 │ va = __riscv_vfnmadd_vv_f16m1_rm(va, va, va, __RISCV_FRM_RDN, vl);
58 │ va = __riscv_vfmsac_vv_f16m1(va, va, va, vl);
59 │ __riscv_vse16_v_f16m1(ptr_b, va, vl);
60 │ }
61 │
62 │ int main(){
63 │ initialize();
64 │
65 │ int avl = dataLen;
66 │ float16_t* ptr_a = a; float16_t* ptr_b = b;
67 │ size_t vl = __riscv_vsetvl_e16m1(avl);
68 │ vfloat16m1_t va = __riscv_vle16_v_f16m1(ptr_a, vl);
69 │ va = __riscv_vfnmadd_vv_f16m1_rm(va, va, va, __RISCV_FRM_RDN, vl);
70 │ va = __riscv_vfmsac_vv_f16m1(va, va, va, vl);
71 │ __riscv_vse16_v_f16m1(ptr_b, va, vl);
72 │
73 │ print_result ();
74 │
75 │ return 0;
76 │ }