From: Richard Sandiford <rdsandiford@googlemail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: gcc-patches@gcc.gnu.org, ebotcazou@adacore.com
Subject: Re: RFC: PR rtl-optimization/52876: Sign extend 32 to 64bit then clear upper 32bits fails O1 or higher
Date: Wed, 11 Apr 2012 14:21:00 -0000 [thread overview]
Message-ID: <g4hawqnycn.fsf@richards-thinkpad.stglab.manchester.uk.ibm.com> (raw)
In-Reply-To: <20120405184839.GA4858@intel.com> (H. J. Lu's message of "Thu, 5 Apr 2012 11:48:39 -0700")
"H.J. Lu" <hongjiu.lu@intel.com> writes:
> Hi,
>
> CSE turns (reg:DI 64)
>
> (insn 6 3 7 2 (set (reg:DI 64)
> (sign_extend:DI (subreg/u:SI (reg/v/f:DI 63 [ addr ]) 0))) x.i:6 122
> {*extendsidi2_rex64} (nil))
>
> into (reg/f:DI 64 [ addr ]). But nonzero_bits1 in rtlanal.c has
>
> #if defined(POINTERS_EXTEND_UNSIGNED) && !defined(HAVE_ptr_extend)
> /* If pointers extend unsigned and this is a pointer in Pmode, say that
> all the bits above ptr_mode are known to be zero. */
> /* As we do not know which address space the pointer is refering to,
> we can do this only if the target does not support different pointer
> or address modes depending on the address space. */
> if (target_default_pointer_address_modes_p ()
> && POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode
> && REG_POINTER (x))
> nonzero &= GET_MODE_MASK (ptr_mode);
> #endif
>
> Setting REG_POINTER with incompatible pointer sign extension is wrong.
> This patch adds a bool parameter to set_reg_attrs_from_value to
> indicate if a register can be marked as a pointer. Does it look OK?
>
> Thanks.
>
>
> H.J.
> ---
> gcc/
>
> 2012-04-05 H.J. Lu <hongjiu.lu@intel.com>
>
> PR rtl-optimization/52876
> * emit-rtl.c (set_reg_attrs_from_value): Add a bool parameter
> to indicate if a register can be a pointer.
> (gen_reg_rtx_and_attrs): Pass true to set_reg_attrs_from_value.
> (set_reg_attrs_for_parm): Likewise.
>
> * emit-rtl.h (set_reg_attrs_from_value): Add a bool parameter.
>
> * reginfo.c (reg_scan_mark_refs): Pass false to
> set_reg_attrs_from_value with incompatible pointer sign
> extension.
Regardless of how it is currently used, I think gen_reg_rtx_and_attrs
(another caller to set_reg_attrs_from_value) is supposed to be a fairly
general function. So rather than apply a fix specific to regscan,
I think it would be cleaner to redefine set_reg_attrs_from_value as
taking an arbitrary value. The whole while loop:
while (GET_CODE (src) == SIGN_EXTEND
|| GET_CODE (src) == ZERO_EXTEND
|| GET_CODE (src) == TRUNCATE
|| (GET_CODE (src) == SUBREG && subreg_lowpart_p (src)))
src = XEXP (src, 0);
would then move to set_reg_attrs_from_value, and the "can be pointer"
thing hidden there. The regscan code would just be:
if (REG_P (dest) && !REG_ATTRS (dest))
set_reg_attrs_from_value (dest, src);
Richard
next prev parent reply other threads:[~2012-04-11 14:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-05 18:48 H.J. Lu
2012-04-10 14:49 ` H.J. Lu
2012-04-11 14:21 ` Richard Sandiford [this message]
2012-04-11 17:21 ` H.J. Lu
2012-04-11 18:53 ` 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=g4hawqnycn.fsf@richards-thinkpad.stglab.manchester.uk.ibm.com \
--to=rdsandiford@googlemail.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@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).