https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119832
--- Comment #2 from Li Pan <pan2.li at intel dot com> --- More details. 7 --- mode change from 10 -> 7 // NONE => DYN <<< 8 --- restore mode is dyn and prev is not call 9 --- mode change from 7 -> 9 // DYN => CALL 10 --- mode change from 10 -> 9 // NONE => CALL 11 --- mode change from 9 -> 7 // CALL => DYN <<< 12 --- backup from prev is call --- 13 --- mode change from 10 -> 9 // NONE => CALL 14 --- mode change from 9 -> 7 // CALL => DYN <<< 15 --- backup from prev is call --- 16 --- mode change from 7 -> 9 // DYN => CALL 17 --- mode change from 7 -> 8 // DYN => EXIT When prev mode is CALL, will always backup frm, and then we meet NONE => DYN, as kito mentioned, the restore will be emitted if mode is dyn and prev mode is not CALL. Not very sure if we can take care of this safely inside the riscv_emit_frm_mode_set right now. Let me reconsider this.