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.