Thanks Robin. Committed with change nuints into nunits
and change mode_idx into 0 for vnshift and vnclip. juzhe.zh...@rivai.ai From: Robin Dapp Date: 2023-11-02 23:18 To: Juzhe-Zhong; gcc-patches CC: rdapp.gcc; kito.cheng; kito.cheng; jeffreyalaw Subject: Re: [PATCH V2] RISC-V: Fix redundant vsetvl in fixed-vlmax vectorized codes[PR112326] Hi Juzhe, in principle this LGTM. It could use some function comments, though ;) > +imm_avl_p (machine_mode mode) > { > poly_uint64 nuints = GET_MODE_NUNITS (mode); > > return nuints.is_constant () > - /* The vsetivli can only hold register 0~31. */ > - ? (IN_RANGE (nuints.to_constant (), 0, 31)) > - /* Only allowed in VLS-VLMAX mode. */ > - : false; > + /* The vsetivli can only hold register 0~31. */ > + ? (IN_RANGE (nuints.to_constant (), 0, 31)) > + /* Only allowed in VLS-VLMAX mode. */ > + : false; > } Please replace nuints (or untis) with nunits here everywhere. > +;; The index of operand[] represents the machine mode of the instruction. > +(define_attr "mode_idx" "" > + (cond [(eq_attr "type" > "vlde,vste,vldm,vstm,vlds,vsts,vldux,vldox,vldff,vldr,vstr,\ > + vlsegde,vlsegds,vlsegdux,vlsegdox,vlsegdff,vialu,vext,vicalu,\ > + vshift,vicmp,viminmax,vimul,vidiv,vimuladd,vimerge,vimov,\ > + vsalu,vaalu,vsmul,vsshift,vfalu,vfmul,vfdiv,vfmuladd,vfsqrt,vfrecp,\ > + vfcmp,vfminmax,vfsgnj,vfclass,vfmerge,vfmov,\ > + vfcvtitof,vfncvtitof,vfncvtftoi,vfncvtftof,vmalu,vmiota,vmidx,\ > + > vimovxv,vfmovfv,vslideup,vslidedown,vislide1up,vislide1down,vfslide1up,vfslide1down,\ > + vgather,vcompress,vmov") > + (const_int 0) > + > + (eq_attr "type" "vimovvx,vfmovvf") > + (const_int 1) > + > + (eq_attr "type" "vssegte,vnshift,vmpop,vmffs") > + (const_int 2) I'm not that fond of the growing number of necessary indices even though I realize that it's the most painless way for now. Why is vnshift "2" and not "0", though? "4" for vnclip also looks dubious. I didn't go through all of them. Regards Robin