From: "H.J. Lu" <hjl.tools@gmail.com>
To: Paolo Bonzini <bonzini@gnu.org>
Cc: Uros Bizjak <ubizjak@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: PING: PATCH [4/n]: Prepare x32: Permute the conversion and addition if one operand is a constant
Date: Fri, 29 Jul 2011 13:29:00 -0000 [thread overview]
Message-ID: <CAMe9rOrhLsBDAjRWr7n+dzPLHA0hvJ=ZjF2Q3143z5-NtOGdjA@mail.gmail.com> (raw)
In-Reply-To: <4E312C6A.8040301@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]
On Thu, Jul 28, 2011 at 2:31 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
> On 07/28/2011 11:30 AM, Uros Bizjak wrote:
>>
>> > convert_memory_address_addr_space has a special PLUS/MULT case for
>> > POINTERS_EXTEND_UNSIGNED< 0. ?It turns out that it is also needed
>> > for all Pmode != ptr_mode cases. ?OK for trunk?
>> > 2011-06-11 ?H.J. Lu ?<hongjiu.lu@intel.com>
>> >
>> > ? ? ? ?PR middle-end/47727
>> > ? ? ? ?* explow.c (convert_memory_address_addr_space): Permute the
>> > ? ? ? ?conversion and addition if one operand is a constant.
>>
>> Do we still need this patch? With recent target changes the testcase
>> from PR can be compiled without problems with a gcc from an unpatched
>> trunk.
>
> Given the communication difficulties, I hope not...
>
> Paolo
>
Here is the updated patch. OK for trunk?
Thanks.
--
H.J.
---
2011-07-28 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/49721
* explow.c (convert_memory_address_addr_space_1): New.
(convert_memory_address_addr_space): Use it.
* expr.c (convert_modes_1): New.
(convert_modes): Use it.
* expr.h (convert_modes_1): New.
* rtl.h (convert_memory_address_addr_space_1): New.
(convert_memory_address_1): Likewise.
* simplify-rtx.c (simplify_unary_operation_1): Call
convert_memory_address_1 instead of convert_memory_address.
[-- Attachment #2: gcc-x32-pr49721-4.patch --]
[-- Type: text/x-diff, Size: 7794 bytes --]
2011-07-28 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/49721
* explow.c (convert_memory_address_addr_space_1): New.
(convert_memory_address_addr_space): Use it.
* expr.c (convert_modes_1): New.
(convert_modes): Use it.
* expr.h (convert_modes_1): New.
* rtl.h (convert_memory_address_addr_space_1): New.
(convert_memory_address_1): Likewise.
* simplify-rtx.c (simplify_unary_operation_1): Call
convert_memory_address_1 instead of convert_memory_address.
diff --git a/gcc/explow.c b/gcc/explow.c
index 3c692f4..069a68a 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -320,8 +320,9 @@ break_out_memory_refs (rtx x)
arithmetic insns can be used. */
rtx
-convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
- rtx x, addr_space_t as ATTRIBUTE_UNUSED)
+convert_memory_address_addr_space_1 (enum machine_mode to_mode ATTRIBUTE_UNUSED,
+ rtx x, addr_space_t as ATTRIBUTE_UNUSED,
+ bool no_emit ATTRIBUTE_UNUSED)
{
#ifndef POINTERS_EXTEND_UNSIGNED
gcc_assert (GET_MODE (x) == to_mode || GET_MODE (x) == VOIDmode);
@@ -377,28 +378,27 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
break;
case CONST:
- return gen_rtx_CONST (to_mode,
- convert_memory_address_addr_space
- (to_mode, XEXP (x, 0), as));
+ temp = convert_memory_address_addr_space_1 (to_mode, XEXP (x, 0),
+ as, no_emit);
+ return temp ? gen_rtx_CONST (to_mode, temp) : temp;
break;
case PLUS:
case MULT:
- /* For addition we can safely permute the conversion and addition
- operation if one operand is a constant and converting the constant
- does not change it or if one operand is a constant and we are
- using a ptr_extend instruction (POINTERS_EXTEND_UNSIGNED < 0).
+ /* FIXME: Is this really safe for POINTERS_EXTEND_UNSIGNED < 0?
+ For addition, we can safely permute the conversion and addition
+ operation if one operand is a constant and we are using a
+ ptr_extend instruction (POINTERS_EXTEND_UNSIGNED < 0).
+
We can always safely permute them if we are making the address
narrower. */
if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode)
|| (GET_CODE (x) == PLUS
&& CONST_INT_P (XEXP (x, 1))
- && (XEXP (x, 1) == convert_memory_address_addr_space
- (to_mode, XEXP (x, 1), as)
- || POINTERS_EXTEND_UNSIGNED < 0)))
+ && POINTERS_EXTEND_UNSIGNED < 0))
return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
- convert_memory_address_addr_space
- (to_mode, XEXP (x, 0), as),
+ convert_memory_address_addr_space_1
+ (to_mode, XEXP (x, 0), as, no_emit),
XEXP (x, 1));
break;
@@ -406,10 +406,17 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
break;
}
- return convert_modes (to_mode, from_mode,
- x, POINTERS_EXTEND_UNSIGNED);
+ return convert_modes_1 (to_mode, from_mode, x,
+ POINTERS_EXTEND_UNSIGNED, no_emit);
#endif /* defined(POINTERS_EXTEND_UNSIGNED) */
}
+
+rtx
+convert_memory_address_addr_space (enum machine_mode to_mode,
+ rtx x, addr_space_t as)
+{
+ return convert_memory_address_addr_space_1 (to_mode, x, as, false);
+}
\f
/* Return something equivalent to X but valid as a memory address for something
of mode MODE in the named address space AS. When X is not itself valid,
diff --git a/gcc/expr.c b/gcc/expr.c
index 0988c51..8aec0a5 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -696,13 +696,16 @@ convert_to_mode (enum machine_mode mode, rtx x, int unsignedp)
Both modes may be floating, or both integer.
UNSIGNEDP is nonzero if X is an unsigned value.
+ If NO_EMIT is true, don't emit any instructions.
+
This can be done by referring to a part of X in place
or by copying to a new temporary with conversion.
You can give VOIDmode for OLDMODE, if you are sure X has a nonvoid mode. */
rtx
-convert_modes (enum machine_mode mode, enum machine_mode oldmode, rtx x, int unsignedp)
+convert_modes_1 (enum machine_mode mode, enum machine_mode oldmode,
+ rtx x, int unsignedp, bool no_emit)
{
rtx temp;
@@ -712,7 +715,16 @@ convert_modes (enum machine_mode mode, enum machine_mode oldmode, rtx x, int uns
if (GET_CODE (x) == SUBREG && SUBREG_PROMOTED_VAR_P (x)
&& GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (mode)
&& SUBREG_PROMOTED_UNSIGNED_P (x) == unsignedp)
- x = gen_lowpart (mode, x);
+ {
+ temp = rtl_hooks.gen_lowpart_no_emit (mode, x);
+ if (temp)
+ x = temp;
+ else
+ {
+ gcc_assert (!no_emit);
+ x = gen_lowpart (mode, x);
+ }
+ }
if (GET_MODE (x) != VOIDmode)
oldmode = GET_MODE (x);
@@ -776,6 +788,10 @@ convert_modes (enum machine_mode mode, enum machine_mode oldmode, rtx x, int uns
return gen_int_mode (val, mode);
}
+ temp = rtl_hooks.gen_lowpart_no_emit (mode, x);
+ if (temp)
+ return temp;
+ gcc_assert (!no_emit);
return gen_lowpart (mode, x);
}
@@ -787,10 +803,20 @@ convert_modes (enum machine_mode mode, enum machine_mode oldmode, rtx x, int uns
return simplify_gen_subreg (mode, x, oldmode, 0);
}
+ if (no_emit)
+ return NULL_RTX;
+
temp = gen_reg_rtx (mode);
convert_move (temp, x, unsignedp);
return temp;
}
+
+rtx
+convert_modes (enum machine_mode mode, enum machine_mode oldmode,
+ rtx x, int unsignedp)
+{
+ return convert_modes_1 (mode, oldmode, x, unsignedp, false);
+}
\f
/* Return the largest alignment we can use for doing a move (or store)
of MAX_PIECES. ALIGN is the largest alignment we could use. */
diff --git a/gcc/expr.h b/gcc/expr.h
index 74c608a..dc40196 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -267,6 +267,8 @@ extern rtx convert_to_mode (enum machine_mode, rtx, int);
/* Convert an rtx to MODE from OLDMODE and return the result. */
extern rtx convert_modes (enum machine_mode, enum machine_mode, rtx, int);
+extern rtx convert_modes_1 (enum machine_mode, enum machine_mode, rtx,
+ int, bool);
/* Emit code to move a block Y to a block X. */
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 1490bfe..d471efa 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1658,8 +1658,13 @@ extern int byte_lowpart_offset (enum machine_mode, enum machine_mode);
extern rtx make_safe_from (rtx, rtx);
extern rtx convert_memory_address_addr_space (enum machine_mode, rtx,
addr_space_t);
+extern rtx convert_memory_address_addr_space_1 (enum machine_mode, rtx,
+ addr_space_t, bool);
#define convert_memory_address(to_mode,x) \
convert_memory_address_addr_space ((to_mode), (x), ADDR_SPACE_GENERIC)
+#define convert_memory_address_1(to_mode,x,no_emit) \
+ convert_memory_address_addr_space_1 ((to_mode), (x), \
+ ADDR_SPACE_GENERIC, (no_emit))
extern const char *get_insn_name (int);
extern rtx get_last_insn_anywhere (void);
extern rtx get_first_nonnote_insn (void);
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 2d7d8dd..6090268 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -1150,7 +1150,7 @@ simplify_unary_operation_1 (enum rtx_code code, enum machine_mode mode, rtx op)
&& REG_P (SUBREG_REG (op))
&& REG_POINTER (SUBREG_REG (op))
&& GET_MODE (SUBREG_REG (op)) == Pmode)))
- return convert_memory_address (Pmode, op);
+ return convert_memory_address_1 (Pmode, op, true);
#endif
break;
@@ -1243,7 +1243,7 @@ simplify_unary_operation_1 (enum rtx_code code, enum machine_mode mode, rtx op)
&& REG_P (SUBREG_REG (op))
&& REG_POINTER (SUBREG_REG (op))
&& GET_MODE (SUBREG_REG (op)) == Pmode)))
- return convert_memory_address (Pmode, op);
+ return convert_memory_address_1 (Pmode, op, true);
#endif
break;
next prev parent reply other threads:[~2011-07-29 13:13 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-28 10:24 Uros Bizjak
2011-07-28 10:27 ` Paolo Bonzini
2011-07-29 13:29 ` H.J. Lu [this message]
2011-07-28 18:23 ` Uros Bizjak
2011-07-29 9:32 ` Paolo Bonzini
2011-07-29 9:37 ` Paolo Bonzini
2011-07-30 0:47 ` H.J. Lu
2011-07-30 16:35 ` Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2011-07-05 14:30 H.J. Lu
2011-07-09 21:22 ` H.J. Lu
2011-07-09 21:23 ` Paolo Bonzini
2011-07-09 21:41 ` H.J. Lu
2011-07-10 17:04 ` Paolo Bonzini
2011-07-10 21:16 ` H.J. Lu
2011-07-11 0:48 ` H.J. Lu
2011-07-11 1:14 ` H.J. Lu
2011-07-11 6:49 ` H.J. Lu
2011-07-11 11:09 ` Paolo Bonzini
2011-07-11 15:58 ` H.J. Lu
2011-07-11 16:57 ` H.J. Lu
2011-07-11 17:26 ` H.J. Lu
2011-07-13 16:24 ` Paolo Bonzini
2011-07-13 16:52 ` H.J. Lu
2011-07-13 16:55 ` Paolo Bonzini
2011-07-13 16:58 ` Paolo Bonzini
2011-07-13 18:42 ` H.J. Lu
2011-07-25 10:34 ` Paolo Bonzini
2011-07-27 18:18 ` H.J. Lu
2011-07-27 22:41 ` Paolo Bonzini
2011-07-28 3:11 ` H.J. Lu
2011-07-28 7:59 ` Paolo Bonzini
2014-05-29 4:52 ` Andrew Pinski
2014-05-29 16:13 ` H.J. Lu
2014-05-29 16:23 ` pinskia
2014-05-29 17:09 ` H.J. Lu
2014-05-29 17:20 ` pinskia
2014-05-30 7:18 ` Paolo Bonzini
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='CAMe9rOrhLsBDAjRWr7n+dzPLHA0hvJ=ZjF2Q3143z5-NtOGdjA@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=bonzini@gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=ubizjak@gmail.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).