From: Tamar Christina <Tamar.Christina@arm.com>
To: Richard Sandiford <Richard.Sandiford@arm.com>
Cc: Richard Biener <rguenther@suse.de>, nd <nd@arm.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: RE: [PATCH 1/4]middle-end Vect: Add support for dot-product where the sign for the multiplicant changes.
Date: Mon, 12 Jul 2021 09:56:54 +0000 [thread overview]
Message-ID: <VI1PR08MB53259C129C42CFADD2FDBA8DFF159@VI1PR08MB5325.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <mptbl77j2h1.fsf@arm.com>
> -----Original Message-----
> From: Richard Sandiford <richard.sandiford@arm.com>
> Sent: Monday, July 12, 2021 10:39 AM
> To: Tamar Christina <Tamar.Christina@arm.com>
> Cc: Richard Biener <rguenther@suse.de>; nd <nd@arm.com>; gcc-
> patches@gcc.gnu.org
> Subject: Re: [PATCH 1/4]middle-end Vect: Add support for dot-product
> where the sign for the multiplicant changes.
>
> Tamar Christina <Tamar.Christina@arm.com> writes:
> > Hi,
> >
> >> Richard Sandiford <richard.sandiford@arm.com> writes:
> >> >> @@ -992,21 +1029,27 @@ vect_recog_dot_prod_pattern (vec_info
> >> *vinfo,
> >> >> /* FORNOW. Can continue analyzing the def-use chain when this
> >> >> stmt in
> >> a phi
> >> >> inside the loop (in case we are analyzing an outer-loop). */
> >> >> vect_unpromoted_value unprom0[2];
> >> >> + enum optab_subtype subtype = optab_vector;
> >> >> if (!vect_widened_op_tree (vinfo, mult_vinfo, MULT_EXPR,
> >> WIDEN_MULT_EXPR,
> >> >> - false, 2, unprom0, &half_type))
> >> >> + false, 2, unprom0, &half_type, &subtype))
> >> >> + return NULL;
> >> >> +
> >> >> + if (subtype == optab_vector_mixed_sign
> >> >> + && TYPE_UNSIGNED (unprom_mult.type)
> >> >> + && TYPE_PRECISION (half_type) * 4 > TYPE_PRECISION
> >> >> + (unprom_mult.type))
> >> >> return NULL;
> >> >
> >> > Isn't the final condition here instead that TYPE1 is narrower than TYPE2?
> >> > I.e. we need to reject the case in which we multiply a signed and
> >> > an unsigned value to get a (logically) signed result, but then
> >> > zero-extend it (rather than sign-extend it) to the precision of the
> addition.
> >> >
> >> > That would make the test:
> >> >
> >> > if (subtype == optab_vector_mixed_sign
> >> > && TYPE_UNSIGNED (unprom_mult.type)
> >> > && TYPE_PRECISION (unprom_mult.type) < TYPE_PRECISION (type))
> >> > return NULL;
> >> >
> >> > instead.
> >>
> >> And folding that into the existing test gives:
> >>
> >> /* If there are two widening operations, make sure they agree on the
> sign
> >> of the extension. The result of an optab_vector_mixed_sign operation
> >> is signed; otherwise, the result has the same sign as the operands. */
> >> if (TYPE_PRECISION (unprom_mult.type) != TYPE_PRECISION (type)
> >> && (subtype == optab_vector_mixed_sign
> >> ? TYPE_UNSIGNED (unprom_mult.type)
> >> : TYPE_SIGN (unprom_mult.type) != TYPE_SIGN (half_type)))
> >> return NULL;
> >>
> >
> > I went with the first one which doesn't add the extra constraints for
> > the normal dotproduct as that makes it too restrictive. It's the type
> > of the multiplication that determines the operation so dotproduct can
> > be used a bit more than where we currently do.
> >
> > This was relaxed in an earlier patch.
>
> I didn't mean that we should add extra constraints to the normal case though.
> The existing test I was referring to above was:
>
> /* If there are two widening operations, make sure they agree on
> the sign of the extension. */
> if (TYPE_PRECISION (unprom_mult.type) != TYPE_PRECISION (type)
> && TYPE_SIGN (unprom_mult.type) != TYPE_SIGN (half_type))
> return NULL;
But as I mentioned, this restriction is unneeded and has been removed hence why it's not in my patchset's diff.
It's removed by https://gcc.gnu.org/pipermail/gcc-patches/2021-May/569851.html which Richi conditioned on
the rest of these patches being approved.
This change needlessly blocks test vect-reduc-dot-[2,3,6,7].c from being dotproducts for instance
It's also part of the deficiency between GCC codegen and Clang https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88492#c6
Regards,
Tamar
>
> Although this existing test makes sense for the normal case, IMO testing
> TYPE_SIGN (half_type) doesn't make sense for the mixed-sign case. I think
> we should therefore replace the existing test with:
>
> /* If there are two widening operations, make sure they agree on the sign
> of the extension. The result of an optab_vector_mixed_sign operation
> is signed; otherwise, the result has the same sign as the operands. */
> if (TYPE_PRECISION (unprom_mult.type) != TYPE_PRECISION (type)
> && (subtype == optab_vector_mixed_sign
> ? TYPE_UNSIGNED (unprom_mult.type)
> : TYPE_SIGN (unprom_mult.type) != TYPE_SIGN (half_type)))
> return NULL;
>
> rather than add a separate condition for the mixed-sign case.
> The behaviour of the normal case is the same both ways.
>
> Thanks,
> Richard
>
next prev parent reply other threads:[~2021-07-12 9:57 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-05 17:38 Tamar Christina
2021-05-05 17:38 ` [PATCH 2/4]AArch64: Add support for sign differing dot-product usdot for NEON and SVE Tamar Christina
2021-05-10 16:49 ` Richard Sandiford
2021-05-25 14:57 ` Tamar Christina
2021-05-26 8:50 ` Richard Sandiford
2021-05-05 17:39 ` [PATCH 3/4][AArch32]: Add support for sign differing dot-product usdot for NEON Tamar Christina
2021-05-05 17:42 ` FW: " Tamar Christina
[not found] ` <VI1PR08MB5325B832EE3BB6139886C0E9FF259@VI1PR08MB5325.eurprd08.prod.outlook.com>
2021-05-25 15:02 ` Tamar Christina
2021-05-26 10:45 ` Kyrylo Tkachov
2021-05-06 9:23 ` Christophe Lyon
2021-05-06 9:27 ` Tamar Christina
2021-05-05 17:39 ` [PATCH 4/4]middle-end: Add tests middle end generic tests for sign differing dotproduct Tamar Christina
[not found] ` <VI1PR08MB532511701573C18A33AC6291FF259@VI1PR08MB5325.eurprd08.prod.outlook.com>
2021-05-25 15:01 ` FW: " Tamar Christina
[not found] ` <11s2181-8856-30rq-26or-84q8o7qrr2o@fhfr.qr>
2021-05-26 8:48 ` Tamar Christina
2021-06-14 12:08 ` Tamar Christina
2021-05-07 11:45 ` [PATCH 1/4]middle-end Vect: Add support for dot-product where the sign for the multiplicant changes Richard Biener
2021-05-07 12:42 ` Tamar Christina
2021-05-10 11:39 ` Richard Biener
2021-05-10 12:58 ` Tamar Christina
2021-05-10 13:29 ` Richard Biener
2021-05-25 14:57 ` Tamar Christina
2021-05-26 8:56 ` Richard Biener
2021-06-02 9:28 ` Tamar Christina
2021-06-04 10:12 ` Tamar Christina
2021-06-07 10:10 ` Richard Sandiford
2021-06-14 12:06 ` Tamar Christina
2021-06-21 8:11 ` Tamar Christina
2021-06-22 10:56 ` Richard Sandiford
2021-06-22 11:16 ` Richard Sandiford
2021-07-12 9:18 ` Tamar Christina
2021-07-12 9:39 ` Richard Sandiford
2021-07-12 9:56 ` Tamar Christina [this message]
2021-07-12 10:25 ` Richard Sandiford
2021-07-12 12:29 ` Tamar Christina
2021-07-12 14:55 ` Richard Sandiford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=VI1PR08MB53259C129C42CFADD2FDBA8DFF159@VI1PR08MB5325.eurprd08.prod.outlook.com \
--to=tamar.christina@arm.com \
--cc=Richard.Sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nd@arm.com \
--cc=rguenther@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).