It's OK, and your version did have more right thing in riscv_emit_int_compare, so do you mind I include that part and add you to coauthor in the patch in future?
Jiawei <[email protected]> 於 2026年6月4日週四 下午9:14寫道: > > Thanks for the comments. > > I just noticed there is already a downstream implementation in the SiFive > riscv-gcc tree: > > https://github.com/riscv/zibi/issues/2 > > Sorry that I missed that before sending this RFC. > > Since there is already an existing implementation, I will stop pursuing this > RFC to avoid duplicating the work. Please feel free to upstream the > downstream > patch directly if you prefer. I am happy to help test it and adapt it > against > current GCC trunk if needed. > > > Best regards, > > Jiawei > > 在 2026/6/4 20:47, Kito Cheng 写道: > >> diff --git a/gcc/config/riscv/riscv-ext.def > >> b/gcc/config/riscv/riscv-ext.def > >> index b9ef0c5ea05..ef8d0400f5d 100644 > >> --- a/gcc/config/riscv/riscv-ext.def > >> +++ b/gcc/config/riscv/riscv-ext.def > >> @@ -220,6 +220,19 @@ DEFINE_RISCV_EXT( > >> /* BITMASK_BIT_POSITION*/ 7, > >> /* EXTRA_EXTENSION_FLAGS */ 0) > >> > >> +DEFINE_RISCV_EXT( > >> + /* NAME */ zibi, > >> + /* UPPERCASE_NAME */ ZIBI, > >> + /* FULL_NAME */ "Branch with immediate", > >> + /* DESC */ "", > >> + /* URL */ , > >> + /* DEP_EXTS */ ({}), > >> + /* SUPPORTED_VERSIONS */ ({{1, 0}}), > > It's 0.6 on the repo? > > > >> diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md > >> index 2055e5c4a9d..38fd5d9e9ac 100644 > >> --- a/gcc/config/riscv/riscv.md > >> +++ b/gcc/config/riscv/riscv.md > >> @@ -3435,6 +3435,32 @@ > >> [(set_attr "type" "branch") > >> (set_attr "mode" "none")]) > >> > >> +(define_insn "*branch_zibi<mode>" > > I incline this merge with *branch<mode> pattern and then split that > > into eqne and others > > (e.g. *branch<mode>_eqne *branch<mode>_relational_comparison) > > and control the zibi by `ext` attribute > > > >> + [(set (pc) > >> + (if_then_else > >> + (match_operator 1 "equality_operator" > >> + [(match_operand:X 2 "register_operand" "r") > >> + (match_operand:X 3 "zibi_cimm_operand" "zibi")]) > >> + (label_ref (match_operand 0 "" "")) > >> + (pc)))] >
