Hi Maciej: Thanks for detail analysis and performance number report, I am concern about this patch might let compiler schedule the fsflags/frflags with other floating point instructions, and the major issue is we didn't model fflags right in GCC as you mentioned in the first email. So I think we should model this right before we split that, I guess that would be a bunch of work: 1. Add fflags to the hard register list. 2. Add (clobber (reg fflags)) or (set (reg fflags) (fpop (operands...))) to those floating point operations which might change fflags 3. Rewrite riscv_frflags and riscv_fsflags pattern by right RTL pattern: (set (reg) (reg fflags)) and (set (reg fflags) (reg)). 4. Then split *f_quiet4_default and *f_quiet4_snan pattern. However I am not sure about the code gen impact of 2, especially the impact to the combine pass, not sure if you are interested to give a try? And, I did some hack for part of this approach (1+3+4) got following result for "__builtin_isless (x, y) + __builtin_isless (x, z)": fltlt: frflags a4 # 8 [c=4 l=4] riscv_frflags flt.d a5,fa0,fa1 # 14 [c=4 l=4] *cstoredfdi4 flt.d a0,fa0,fa2 # 17 [c=4 l=4] *cstoredfdi4 fsflags a4 # 18 [c=4 l=4] riscv_fsflags add a0,a0,a5 # 30 [c=4 l=4] adddi3/0 ret # 40 [c=0 l=4] simple_return Verbose version: fltlt: #(insn 8 5 9 (set (reg:SI 14 a4 [88]) # (reg:SI 66 fflags)) "x.c":5:10 258 {riscv_frflags} # (expr_list:REG_DEAD (reg:SI 66 fflags) # (nil))) frflags a4 # 8 [c=4 l=4] riscv_frflags #(insn 14 11 15 (parallel [ # (set (reg:DI 15 a5 [90]) # (lt:DI (reg/v:DF 42 fa0 [orig:81 x ] [81]) # (reg:DF 43 fa1 [101]))) # (clobber:SI (reg:SI 66 fflags)) # ]) "x.c":5:10 197 {*cstoredfdi4} # (expr_list:REG_DEAD (reg:DF 43 fa1 [101]) # (expr_list:REG_UNUSED (reg:SI 66 fflags) # (nil)))) flt.d a5,fa0,fa1 # 14 [c=4 l=4] *cstoredfdi4 #(insn 17 15 18 (parallel [ # (set (reg:DI 10 a0 [94]) # (lt:DI (reg/v:DF 42 fa0 [orig:81 x ] [81]) # (reg:DF 44 fa2 [102]))) # (clobber:SI (reg:SI 66 fflags)) # ]) "x.c":5:36 197 {*cstoredfdi4} # (expr_list:REG_DEAD (reg:DF 44 fa2 [102]) # (expr_list:REG_DEAD (reg/v:DF 42 fa0 [orig:81 x ] [81]) # (expr_list:REG_UNUSED (reg:SI 66 fflags) # (nil))))) flt.d a0,fa0,fa2 # 17 [c=4 l=4] *cstoredfdi4 #(insn 18 17 19 (set (reg:SI 66 fflags) # (reg:SI 14 a4 [88])) "x.c":5:36 259 {riscv_fsflags} # (expr_list:REG_DEAD (reg:SI 14 a4 [88]) # (nil))) fsflags a4 # 18 [c=4 l=4] riscv_fsflags #(insn 30 25 31 (set (reg/i:DI 10 a0) # (plus:DI (reg:DI 10 a0 [94]) # (reg:DI 15 a5 [90]))) "x.c":6:1 4 {adddi3} # (expr_list:REG_DEAD (reg:DI 15 a5 [90]) # (nil))) add a0,a0,a5 # 30 [c=4 l=4] adddi3/0 #(jump_insn 40 39 41 (simple_return) "x.c":6:1 244 {simple_return} # (nil) # -> simple_return) ret # 40 [c=0 l=4] simple_return ---- But this hack add an extra use of fflags to prevent FFLAGS getting CSEed, patch attached.