On Fri, Dec 12, 2025 at 12:10 AM Robin Dapp <[email protected]> wrote: > > > Could you provide testcase to verified select_vl begin generated for VLS > > mode? > > I can't found testcase, I tried param-autovec-mode.c > > and select_vl-2.c (with --param=riscv-autovec-mode=V4QI) > > and both cases are generated MIN_EXPR rather than SELECT_VL. > > Really? I thought it would trigger in param-autovec-mode but haven't verified > the code-gen. I mean it's not terribly common, just for VLS epilogue loops. > But yes, I'll add a more specific test.
Oh, I found that is because I didn't add ZBB into -march when I was testing, but that also indicates a fun fact is...GCC will just use MIN_EXPR if the select_VL pattern is not available. And I didn't notice there is " && TARGET_ZBB" in the md, anyway, this patch seems right, but need testcase, maybe copy & paste with param-autovec-mode.c and select_vl-2.c then add _zbb to the march string. > > > ^^^ I think we should not assert TARGET_ZBB here, although I that's > > because we try to expand UMIN > > > >> + rtx nunits_reg = gen_reg_rtx (Pmode); > >> + emit_move_insn (nunits_reg, GEN_INT (nunits.to_constant ())); > >> + rtx avl_adj = gen_reg_rtx (Pmode); > >> + emit_move_insn (avl_adj, simplify_gen_binary > >> + (UMIN, Pmode, ops[1], nunits_reg)); > > > > Maybe expand_simple_binop rather than simplify_gen_binary here to > > avoid we require ZBB > > I refrained from doing so on purpose because the umin codegen is very verbose > and would drown a lot of the vectorization benefit for small loops. I'd much > rather have the non-len VLS flow when Zbb is unavailable. > > -- > Regards > Robin >o
