From: Richard Sandiford <rdsandiford@googlemail.com>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: PR 49145: Another (zero_extend (const_int ...)) in combine
Date: Sat, 04 Jun 2011 21:22:00 -0000 [thread overview]
Message-ID: <87oc2dmgwn.fsf@firetop.home> (raw)
In-Reply-To: <201106012220.49874.ebotcazou@adacore.com> (Eric Botcazou's message of "Wed, 1 Jun 2011 22:20:49 +0200")
Eric Botcazou <ebotcazou@adacore.com> writes:
> SUBREG and ZERO_EXTEND of CONST_INTs are treated somewhat specially in the
> entire file, see for example do_SUBST. This isn't the case for other unary
> operators, presumably because this isn't really necessary here. So I'm not
> convinced that such a generalization is really a good thing in this case.
OK. The version below just adds a special case tomake_compound_operation
instead. As before, I've restricted the simplification to constants,
so that we don't inadvertently undo the effects of m_c_o itself.
Tested on x86_64-linux-gnu and mips-linux-gnu. OK for trunk?
Richard
gcc/
PR rtl-optimization/49145
* combine.c (make_compound_operation): Handle ZERO_EXTEND specially.
gcc/testsuite/
PR rtl-optimization/49145
From Ryan Mansfield
* gcc.c-torture/compile/pr49145.c: New test.
Index: gcc/combine.c
===================================================================
--- gcc/combine.c 2011-06-01 22:09:09.000000000 +0100
+++ gcc/combine.c 2011-06-01 22:09:26.000000000 +0100
@@ -7881,7 +7881,20 @@ make_compound_operation (rtx x, enum rtx
code = GET_CODE (x);
}
- /* Now recursively process each operand of this operation. */
+ /* Now recursively process each operand of this operation. We need to
+ handle ZERO_EXTEND specially so that we don't lose track of the
+ inner mode. */
+ if (GET_CODE (x) == ZERO_EXTEND)
+ {
+ new_rtx = make_compound_operation (XEXP (x, 0), next_code);
+ tem = simplify_const_unary_operation (ZERO_EXTEND, GET_MODE (x),
+ new_rtx, GET_MODE (XEXP (x, 0)));
+ if (tem)
+ return tem;
+ SUBST (XEXP (x, 0), new_rtx);
+ return x;
+ }
+
fmt = GET_RTX_FORMAT (code);
for (i = 0; i < GET_RTX_LENGTH (code); i++)
if (fmt[i] == 'e')
Index: gcc/testsuite/gcc.c-torture/compile/pr49145.c
===================================================================
--- /dev/null 2011-06-04 08:47:56.158317425 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr49145.c 2011-06-01 22:09:26.000000000 +0100
@@ -0,0 +1,30 @@
+static int
+func1 (int a, int b)
+{
+ return b ? a : a / b;
+}
+
+static unsigned char
+func2 (unsigned char a, int b)
+{
+ return b ? a : b;
+}
+
+int i;
+
+void
+func3 (const int arg)
+{
+ for (i = 0; i != 10; i = foo ())
+ {
+ if (!arg)
+ {
+ int j;
+ for (j = 0; j < 5; j += 1)
+ {
+ int *ptr;
+ *ptr = func2 (func1 (arg, *ptr), foo (arg));
+ }
+ }
+ }
+}
next prev parent reply other threads:[~2011-06-04 21:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-29 9:30 Richard Sandiford
2011-06-01 20:21 ` Eric Botcazou
2011-06-04 21:22 ` Richard Sandiford [this message]
2011-06-05 22:52 ` Eric Botcazou
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=87oc2dmgwn.fsf@firetop.home \
--to=rdsandiford@googlemail.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/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).