Committed with the example in commit log updated, thanks all. Pan
-----Original Message----- From: Li, Pan2 <pan2...@intel.com> Sent: Wednesday, June 5, 2024 4:38 PM To: Uros Bizjak <ubiz...@gmail.com> Cc: Richard Biener <richard.guent...@gmail.com>; gcc-patches@gcc.gnu.org; juzhe.zh...@rivai.ai; kito.ch...@gmail.com; tamar.christ...@arm.com Subject: RE: [PATCH v1] Internal-fn: Support new IFN SAT_SUB for unsigned scalar int > I see. x86 doesn't have scalar saturating instructions, so the scalar > version indeed can't be converted. > I will amend x86 testcases after the vector part of your patch is committed. Thanks for the confirmation. Just curious, the .SAT_SUB for scalar has sorts of forms, like a branch version as below. .SAT_SUB (x, y) = x > y ? x - y : 0. // or leverage __builtin_sub_overflow here It is reasonable to implement the scalar .SAT_SUB for x86? Given somehow we can eliminate the branch here. Pan -----Original Message----- From: Uros Bizjak <ubiz...@gmail.com> Sent: Wednesday, June 5, 2024 4:30 PM To: Li, Pan2 <pan2...@intel.com> Cc: Richard Biener <richard.guent...@gmail.com>; gcc-patches@gcc.gnu.org; juzhe.zh...@rivai.ai; kito.ch...@gmail.com; tamar.christ...@arm.com Subject: Re: [PATCH v1] Internal-fn: Support new IFN SAT_SUB for unsigned scalar int On Wed, Jun 5, 2024 at 10:22 AM Li, Pan2 <pan2...@intel.com> wrote: > > > Is the above testcase correct? You need "(x + y)" as the first term. > > Thanks for comments, should be copy issue here, you can take SAT_SUB (x, y) > => (x - y) & (-(TYPE)(x >= y)) or below template for reference. > > +#define DEF_SAT_U_SUB_FMT_1(T) \ > +T __attribute__((noinline)) \ > +sat_u_sub_##T##_fmt_1 (T x, T y) \ > +{ \ > + return (x - y) & (-(T)(x >= y)); \ > +} > + > +#define DEF_SAT_U_SUB_FMT_2(T) \ > +T __attribute__((noinline)) \ > +sat_u_sub_##T##_fmt_2 (T x, T y) \ > +{ \ > + return (x - y) & (-(T)(x > y)); \ > +} > > > BTW: After applying your patch, I'm not able to produce .SAT_SUB with > > x86_64 and the following testcase: > > You mean vectorize part? This patch is only for unsigned scalar int (see > title) and the below is the vect part. > Could you please help to double confirm if you cannot see .SAT_SUB after > widen_mul pass in x86 for unsigned scalar int? > Of course, I will have a try later as in the middle of sth. > > https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653024.html I see. x86 doesn't have scalar saturating instructions, so the scalar version indeed can't be converted. I will amend x86 testcases after the vector part of your patch is committed. Thanks, Uros.