https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119164
--- Comment #2 from Vineet Gupta <vineetg at gcc dot gnu.org> --- I tried to address the first issue by changing the helper called to identify call as end of insn (in the presence of the label) - I hope that is the right direction. Anyways per IRC chat, someone suggested following @@ -12144,9 +12144,7 @@ riscv_frm_mode_needed (rtx_insn *cur_insn, int code) if (CALL_P (cur_insn)) { - rtx_insn *insn = next_nonnote_nondebug_insn_bb (cur_insn); - if (!insn) + if (BB_END (BLOCK_FOR_INSN (cur_insn)) == cur_insn) riscv_frm_emit_after_bb_end (cur_insn); This started generating the FRM insn and with following fixup to TARGET_MODE_AFTER hook, the test no longer generates extra frms. @@ -12328,7 +12328,15 @@ riscv_frm_mode_after (rtx_insn *insn, int mode) if (reg_mentioned_p (gen_rtx_REG (SImode, FRM_REGNUM), PATTERN (insn))) - return get_attr_frm_mode (insn); + { + mode = get_attr_frm_mode (insn); + if (mode == riscv_vector::FRM_NONE) + { + rtx_insn *prev_insn = prev_nonnote_nondebug_insn_bb (insn); + if (prev_insn && CALL_P (prev_insn)) + mode = riscv_vector::FRM_DYN; + } + } else return mode;