Thanks so much. Will send V6 patch. juzhe.zhong@rivai.ai From: Bernhard Reutner-Fischer Date: 2023-06-23 00:05 To: juzhe.zhong CC: rep.dot.nop; gcc-patches; rguenther; richard.sandiford Subject: Re: [PATCH V5] VECT: Apply LEN_MASK_{LOAD,STORE} into vectorizer On Thu, 22 Jun 2023 21:53:48 +0800 juzhe.zhong@rivai.ai wrote: > +static bool > +target_supports_mask_load_store_p (machine_mode mode, machine_mode mask_mode, > + bool is_load, internal_fn *ifn) > +{ > + optab op = is_load ? maskload_optab : maskstore_optab; > + optab len_op = is_load ? len_maskload_optab : len_maskstore_optab; > + if (convert_optab_handler (op, mode, mask_mode) != CODE_FOR_nothing) > + { > + if (ifn) > + *ifn = is_load ? IFN_MASK_LOAD : IFN_MASK_STORE; > + return true; > + } > + else if (convert_optab_handler (len_op, mode, mask_mode) != CODE_FOR_nothing) > + { > + *ifn = is_load ? IFN_LEN_MASK_LOAD : IFN_LEN_MASK_STORE; It feels inconsistent that you do not check ifn here. > + return true; > + } > + return false; > +} > +/* Return true if the target has support for len load/store. > + We can support len load/store by either len_{load,store} > + or len_mask{load,store}. > + This helper function checks whether target supports len > + load/store and return corresponding IFN in the last argument > + (IFN_LEN_{LOAD,STORE} or IFN_LEN_MASK_{LOAD,STORE}). */ > + > +static bool > +target_supports_len_load_store_p (machine_mode mode, bool is_load, > + internal_fn *ifn) > +{ > + optab op = is_load ? len_load_optab : len_store_optab; > + optab masked_op = is_load ? len_maskload_optab : len_maskstore_optab; > + > + if (direct_optab_handler (op, mode)) > + { > + if (ifn) > + *ifn = is_load ? IFN_LEN_LOAD : IFN_LEN_STORE; > + return true; > + } > + machine_mode mask_mode; > + if (targetm.vectorize.get_mask_mode (mode).exists (&mask_mode) > + && convert_optab_handler (masked_op, mode, mask_mode) != CODE_FOR_nothing) > + { > + if (ifn) > + *ifn = is_load ? IFN_LEN_MASK_LOAD : IFN_LEN_MASK_STORE; > + return true; > + } > + return false; > +} > + > /* If target supports vector load/store with length for vector mode MODE, > return the corresponding vector mode, otherwise return opt_machine_mode (). > There are two flavors for vector load/store with length, one is to measure > length with bytes, the other is to measure length with lanes. > As len_{load,store} optabs point out, for the flavor with bytes, we use > - VnQI to wrap the other supportable same size vector modes. */ > + VnQI to wrap the other supportable same size vector modes. > + An additional output in the last argumennt which is the IFN pointer. > + We set IFN as LEN_{LOAD,STORE} or LEN_MASK_{LOAD,STORE} according > + which optab is supported in the targe. */ s/argumennt/argument/ s/targe\./target./ thanks,