public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: "H.J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH, i386]: Prevent SImode subregs of stack pointer in addresses
Date: Wed, 01 Aug 2012 12:07:00 -0000	[thread overview]
Message-ID: <CAFULd4YWJLzSFbiUX9c0EFRBtS7+kzspmuOaHnjBPbxWaoEPTQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 568 bytes --]

Hello!

For some reason simplify_subreg does not like stack pointer. We call
simplify_subreg when printing address operands, so we have to prevent
SImode subregs of stack pointers from going into the address.

2012-08-01  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.c (ix86_address_subreg_operand): Reject
	stack pointer.
	(ix86_print_operand_address): Assert that parts.base and parts.index
	are non-NULL after call to simplify_subreg.

Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN.
The patch will be backported to 4.7 branch.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1109 bytes --]

Index: i386.c
===================================================================
--- i386.c	(revision 190005)
+++ i386.c	(working copy)
@@ -11657,6 +11657,10 @@ ix86_address_subreg_operand (rtx op)
   if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
     return false;
 
+  /* simplify_subreg does not handle stack pointer.  */
+  if (REGNO (op) == STACK_POINTER_REGNUM)
+    return false;
+
   /* Allow only SUBREGs of non-eliminable hard registers.  */
   return register_no_elim_operand (op, mode);
 }
@@ -14823,6 +14827,7 @@ ix86_print_operand_address (FILE *file, rtx addr)
       rtx tmp = SUBREG_REG (parts.base);
       parts.base = simplify_subreg (GET_MODE (parts.base),
 				    tmp, GET_MODE (tmp), 0);
+      gcc_assert (parts.base != NULL_RTX);
     }
 
   if (parts.index && GET_CODE (parts.index) == SUBREG)
@@ -14830,6 +14835,7 @@ ix86_print_operand_address (FILE *file, rtx addr)
       rtx tmp = SUBREG_REG (parts.index);
       parts.index = simplify_subreg (GET_MODE (parts.index),
 				     tmp, GET_MODE (tmp), 0);
+      gcc_assert (parts.index != NULL_RTX);
     }
 
   base = parts.base;

                 reply	other threads:[~2012-08-01 12:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAFULd4YWJLzSFbiUX9c0EFRBtS7+kzspmuOaHnjBPbxWaoEPTQ@mail.gmail.com \
    --to=ubizjak@gmail.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).