From: Bernd Schmidt <bernds@codesourcery.com>
To: Andrew Stubbs <ams@codesourcery.com>
Cc: Richard Earnshaw <rearnsha@arm.com>, gcc-patches@gcc.gnu.org
Subject: Re: [patch][ARM] Fix 16-bit -> 64-bit multiply and accumulate
Date: Tue, 03 May 2011 09:08:00 -0000 [thread overview]
Message-ID: <4DBFC5D8.1090009@codesourcery.com> (raw)
In-Reply-To: <4DA823F1.2040907@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 798 bytes --]
On 04/15/2011 12:54 PM, Andrew Stubbs wrote:
> Ping.
Trying to unblock this...
I think the point is that both examples:
long long foolong (long long x, short *a, short *b)
{
return x + (long long)*a * (long long)*b;
}
and
long long foolong (long long x, short *a, short *b)
{
return x + *a * *b;
}
should produce the same code using the maddhidi pattern, and for that to
happen, simplify_rtx must produce a canonical form of the 16->64 bit
widening multiply. The form that already exists in arm.md looks better
so we should pick that.
I tried to fix it with the patch below, which unfortunately doesn't work
since during combine we don't see the SIGN_EXTEND operations inside the
MULT, but two shift operations instead. Maybe you can complete it from here?
Bernd
[-- Attachment #2: srtx-widen.diff --]
[-- Type: text/plain, Size: 2105 bytes --]
Index: gcc/simplify-rtx.c
===================================================================
--- gcc/simplify-rtx.c (revision 173242)
+++ gcc/simplify-rtx.c (working copy)
@@ -1000,6 +1000,23 @@ simplify_unary_operation_1 (enum rtx_cod
&& GET_CODE (XEXP (XEXP (op, 0), 1)) == LABEL_REF)
return XEXP (op, 0);
+ /* Extending a widening multiplication should be canonicalized to
+ a wider widening multiplication. */
+ if (GET_CODE (op) == MULT
+ && GET_CODE (XEXP (op, 0)) == SIGN_EXTEND
+ && GET_CODE (XEXP (op, 1)) == SIGN_EXTEND)
+ {
+ rtx op0 = XEXP (XEXP (op, 0), 0);
+ rtx op1 = XEXP (XEXP (op, 1), 0);
+ enum machine_mode op0_mode = GET_MODE (op0);
+ enum machine_mode op1_mode = GET_MODE (op1);
+ return simplify_gen_binary (MULT, mode,
+ simplify_gen_unary (SIGN_EXTEND, mode,
+ op0, op0_mode),
+ simplify_gen_unary (SIGN_EXTEND, mode,
+ op1, op1_mode));
+ }
+
/* Check for a sign extension of a subreg of a promoted
variable, where the promotion is sign-extended, and the
target mode is the same as the variable's promotion. */
@@ -1071,6 +1088,23 @@ simplify_unary_operation_1 (enum rtx_cod
&& GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (XEXP (op, 0))))
return rtl_hooks.gen_lowpart_no_emit (mode, op);
+ /* Extending a widening multiplication should be canonicalized to
+ a wider widening multiplication. */
+ if (GET_CODE (op) == MULT
+ && GET_CODE (XEXP (op, 0)) == ZERO_EXTEND
+ && GET_CODE (XEXP (op, 1)) == ZERO_EXTEND)
+ {
+ rtx op0 = XEXP (XEXP (op, 0), 0);
+ rtx op1 = XEXP (XEXP (op, 1), 0);
+ enum machine_mode op0_mode = GET_MODE (op0);
+ enum machine_mode op1_mode = GET_MODE (op1);
+ return simplify_gen_binary (MULT, mode,
+ simplify_gen_unary (ZERO_EXTEND, mode,
+ op0, op0_mode),
+ simplify_gen_unary (ZERO_EXTEND, mode,
+ op1, op1_mode));
+ }
+
/* (zero_extend:M (zero_extend:N <X>)) is (zero_extend:M <X>). */
if (GET_CODE (op) == ZERO_EXTEND)
return simplify_gen_unary (ZERO_EXTEND, mode, XEXP (op, 0),
next prev parent reply other threads:[~2011-05-03 9:08 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-09 16:45 Andrew Stubbs
2011-01-27 2:09 ` Ramana Radhakrishnan
2011-01-27 10:46 ` Andrew Stubbs
2011-01-27 19:22 ` Richard Earnshaw
2011-01-28 13:06 ` Andrew Stubbs
2011-01-28 15:08 ` Richard Earnshaw
2011-01-28 15:55 ` Andrew Stubbs
2011-01-28 16:01 ` Richard Earnshaw
2011-03-25 16:27 ` Andrew Stubbs
2011-04-15 11:23 ` Andrew Stubbs
2011-05-03 9:08 ` Bernd Schmidt [this message]
2011-05-03 9:36 ` Andrew Stubbs
2011-05-18 15:32 ` [patch][combine] " Andrew Stubbs
2011-05-19 13:06 ` Bernd Schmidt
2011-05-24 17:51 ` [patch][simplify-rtx] " Andrew Stubbs
2011-05-24 21:00 ` Joseph S. Myers
2011-05-25 9:47 ` Andrew Stubbs
2011-05-25 12:34 ` Joseph S. Myers
2011-05-25 13:42 ` Andrew Stubbs
2011-05-25 13:48 ` Joseph S. Myers
2011-05-25 14:01 ` Andrew Stubbs
2011-05-25 14:27 ` Joseph S. Myers
2011-05-26 13:57 ` Andrew Stubbs
2011-05-26 14:47 ` Joseph S. Myers
2011-06-02 9:46 ` Richard Earnshaw
2011-06-07 11:05 ` Andrew Stubbs
2011-02-09 6:31 ` [patch][ARM] " Hans-Peter Nilsson
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=4DBFC5D8.1090009@codesourcery.com \
--to=bernds@codesourcery.com \
--cc=ams@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rearnsha@arm.com \
/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).