public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Lawrence <alan.lawrence@arm.com>
To: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 2/2][ARM] fix movdi expander to avoid illegal ldrd/strd
Date: Mon, 06 Jul 2015 17:40:00 -0000	[thread overview]
Message-ID: <559ABD76.2050508@arm.com> (raw)
In-Reply-To: <5596B56C.7070505@foss.arm.com>

Richard Earnshaw wrote:
> On 03/07/15 16:27, Alan Lawrence wrote:
>> The previous patch caused a regression in
>> gcc.c-torture/execute/20040709-1.c at -O0 (only), and the new
>> align_rec2.c test fails, both outputting an illegal assembler
>> instruction (ldrd on an odd-numbered reg) from output_move_double in
>> arm.c. Most routes have checks against such an illegal instruction, but
>> expanding a function call can directly name such impossible register
>> (pairs), bypassing the normal checks.
>>
>> gcc/ChangeLog:
>>
>>     * config/arm/arm.md (movdi): Avoid odd-number ldrd/strd in ARM state.
>>
> 
> OK.

Both patches, plus Jakub's test, pushed onto trunk (r221461/5/6), and 
gcc-5-branch (r225467/9/70), with an obvious comment fix to the movdi patch 
(LDRD's into, STRD's from), as below.

Cheers, Alan


Index: gcc/config/arm/arm.md
===================================================================
--- gcc/config/arm/arm.md       (revision 225457)
+++ gcc/config/arm/arm.md       (working copy)
@@ -5481,6 +5481,42 @@
        if (!REG_P (operands[0]))
         operands[1] = force_reg (DImode, operands[1]);
      }
+  if (REG_P (operands[0]) && REGNO (operands[0]) < FIRST_VIRTUAL_REGISTER
+      && !HARD_REGNO_MODE_OK (REGNO (operands[0]), DImode))
+    {
+      /* Avoid LDRD's into an odd-numbered register pair in ARM state
+        when expanding function calls.  */
+      gcc_assert (can_create_pseudo_p ());
+      if (MEM_P (operands[1]) && MEM_VOLATILE_P (operands[1]))
+       {
+         /* Perform load into legal reg pair first, then move.  */
+         rtx reg = gen_reg_rtx (DImode);
+         emit_insn (gen_movdi (reg, operands[1]));
+         operands[1] = reg;
+       }
+      emit_move_insn (gen_lowpart (SImode, operands[0]),
+                     gen_lowpart (SImode, operands[1]));
+      emit_move_insn (gen_highpart (SImode, operands[0]),
+                     gen_highpart (SImode, operands[1]));
+      DONE;
+    }
+  else if (REG_P (operands[1]) && REGNO (operands[1]) < FIRST_VIRTUAL_REGISTER
+          && !HARD_REGNO_MODE_OK (REGNO (operands[1]), DImode))
+    {
+      /* Avoid STRD's from an odd-numbered register pair in ARM state
+        when expanding function prologue.  */
+      gcc_assert (can_create_pseudo_p ());
+      rtx split_dest = (MEM_P (operands[0]) && MEM_VOLATILE_P (operands[0]))
+                      ? gen_reg_rtx (DImode)
+                      : operands[0];
+      emit_move_insn (gen_lowpart (SImode, split_dest),
+                     gen_lowpart (SImode, operands[1]));
+      emit_move_insn (gen_highpart (SImode, split_dest),
+                     gen_highpart (SImode, operands[1]));
+      if (split_dest != operands[0])
+       emit_insn (gen_movdi (operands[0], split_dest));
+      DONE;
+    }
    "
  )


  reply	other threads:[~2015-07-06 17:40 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-03 15:24 [PATCH 0/2][trunk+5 backport][ARM] PR/65956 Implement AAPCS updates for alignment attribute Alan Lawrence
2015-07-03 15:26 ` [PATCH 1/2][ARM] PR/65956 AAPCS update " Alan Lawrence
2015-07-03 16:11   ` Richard Earnshaw
2015-07-03 18:24     ` Richard Biener
2015-07-03 20:43       ` Richard Earnshaw
2015-07-04 10:57         ` Richard Biener
2015-07-04 11:13           ` Jakub Jelinek
2015-07-06 10:01           ` Alan Lawrence
2015-07-05 13:24     ` Eric Botcazou
2015-07-06 11:00       ` Alan Lawrence
2015-07-06 14:23         ` Ramana Radhakrishnan
2015-07-06 16:38           ` Alan Lawrence
2015-07-06 16:40             ` Ramana Radhakrishnan
2015-07-06 16:45               ` Alan Lawrence
2015-11-04 13:14             ` Jakub Jelinek
2015-11-04 21:30               ` Florian Weimer
2015-11-06 16:48               ` Alan Lawrence
2015-11-06 17:00                 ` Jakub Jelinek
2015-11-26 14:05                   ` Alan Lawrence
2015-11-27 13:45                     ` Alan Lawrence
2015-11-27 18:17                       ` Eric Botcazou
2015-11-30 19:40                         ` Florian Weimer
2015-07-07 10:29           ` Alan Lawrence
2015-07-03 17:27   ` Jakub Jelinek
2015-07-03 15:27 ` [PATCH 2/2][ARM] fix movdi expander to avoid illegal ldrd/strd Alan Lawrence
2015-07-03 16:16   ` Richard Earnshaw
2015-07-06 17:40     ` Alan Lawrence [this message]
2015-07-03 17:12 ` [PATCH 0/2][trunk+5 backport][ARM] PR/65956 Implement AAPCS updates for alignment attribute Richard Biener

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=559ABD76.2050508@arm.com \
    --to=alan.lawrence@arm.com \
    --cc=Richard.Earnshaw@foss.arm.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).