public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: "Maciej W. Rozycki" <macro@linux-mips.org>,
	Ulrich Weigand <uweigand@de.ibm.com>
Cc: gcc-patches@gcc.gnu.org, Eric Botcazou <botcazou@adacore.com>,
	Anders Magnusson <ragge@tethuvudet.se>
Subject: Re: [PATCH v3 01/31] PR target/58901: reload: Handle SUBREG of MEM with a mode-dependent address
Date: Mon, 30 Nov 2020 11:51:41 -0700	[thread overview]
Message-ID: <8837efc1-32fa-6899-220c-0a8f5e0ad154@redhat.com> (raw)
In-Reply-To: <alpine.LFD.2.21.2011272049060.656242@eddie.linux-mips.org>



On 11/27/20 1:50 PM, Maciej W. Rozycki wrote:
> From: Matt Thomas <matt@3am-software.com>
>
> Fix an ICE with the handling of RTL expressions like:
>
> (subreg:QI (mem/c:SI (plus:SI (plus:SI (mult:SI (reg/v:SI 0 %r0 [orig:67 i ] [67])
>                     (const_int 4 [0x4]))
>                 (reg/v/f:SI 7 %r7 [orig:59 doacross ] [59]))
>             (const_int 40 [0x28])) [1 MEM[(unsigned int *)doacross_63 + 40B + i_106 * 4]+0 S4 A32]) 0)
>
> that causes the compilation of libgomp to fail:
>
> during RTL pass: reload
> .../libgomp/ordered.c: In function 'GOMP_doacross_wait':
> .../libgomp/ordered.c:507:1: internal compiler error: in change_address_1, at emit-rtl.c:2275
>   507 | }
>       | ^
> 0x10a3462b change_address_1
> 	.../gcc/emit-rtl.c:2275
> 0x10a353a7 adjust_address_1(rtx_def*, machine_mode, poly_int<1u, long>, int, int, int, poly_int<1u, long>)
> 	.../gcc/emit-rtl.c:2409
> 0x10ae2993 alter_subreg(rtx_def**, bool)
> 	.../gcc/final.c:3368
> 0x10ae25cf cleanup_subreg_operands(rtx_insn*)
> 	.../gcc/final.c:3322
> 0x110922a3 reload(rtx_insn*, int)
> 	.../gcc/reload1.c:1232
> 0x10de2bf7 do_reload
> 	.../gcc/ira.c:5812
> 0x10de3377 execute
> 	.../gcc/ira.c:5986
>
> in a `vax-netbsdelf' build, where an attempt is made to change the mode
> of the contained memory reference to the mode of the containing SUBREG.
> Such RTL expressions are produced by the VAX shift and rotate patterns
> (`ashift', `ashiftrt', `rotate', `rotatert') where the count operand
> always has the QI mode regardless of the mode, either SI or DI, of the
> datum shifted or rotated.
>
> Such a mode change cannot work where the memory reference uses the
> indexed addressing mode, where a multiplier is implied that in the VAX
> ISA depends on the width of the memory access requested and therefore
> changing the machine mode would change the address calculation as well.
>
> Avoid the attempt then by forcing the reload of any SUBREGs containing
> a mode-dependent memory reference, also fixing these regressions:
>
> FAIL: gcc.c-torture/compile/pr46883.c   -Os  (internal compiler error)
> FAIL: gcc.c-torture/compile/pr46883.c   -Os  (test for excess errors)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O2  (internal compiler error)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O2  (test for excess errors)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (internal compiler error)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O3 -g  (internal compiler error)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O3 -g  (test for excess errors)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (internal compiler error)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  (internal compiler error)
> FAIL: gcc.c-torture/execute/20120808-1.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
> FAIL: gcc.dg/20050629-1.c (internal compiler error)
> FAIL: gcc.dg/20050629-1.c (test for excess errors)
> FAIL: c-c++-common/torture/pr53505.c   -Os  (internal compiler error)
> FAIL: c-c++-common/torture/pr53505.c   -Os  (test for excess errors)
> FAIL: gfortran.dg/coarray_failed_images_1.f08   -Os  (internal compiler error)
> FAIL: gfortran.dg/coarray_stopped_images_1.f08   -Os  (internal compiler error)
>
> With test case #0 included it causes a reload with:
>
> (insn 15 14 16 4 (set (reg:SI 31)
>         (ashift:SI (const_int 1 [0x1])
>             (subreg:QI (reg:SI 30 [ MEM[(int *)s_8(D) + 4B + _5 * 4] ]) 0))) "pr58901-0.c":15:12 94 {ashlsi3}
>      (expr_list:REG_DEAD (reg:SI 30 [ MEM[(int *)s_8(D) + 4B + _5 * 4] ])
>         (nil)))
>
> as follows:
>
> Reloads for insn # 15
> Reload 0: reload_in (SI) = (reg:SI 30 [ MEM[(int *)s_8(D) + 4B + _5 * 4] ])
> 	ALL_REGS, RELOAD_FOR_INPUT (opnum = 2)
> 	reload_in_reg: (reg:SI 30 [ MEM[(int *)s_8(D) + 4B + _5 * 4] ])
> 	reload_reg_rtx: (reg:SI 5 %r5)
>
> resulting in:
>
> (insn 37 14 15 4 (set (reg:SI 5 %r5)
>         (mem/c:SI (plus:SI (plus:SI (mult:SI (reg/v:SI 1 %r1 [orig:25 i ] [25])
>                         (const_int 4 [0x4]))
>                     (reg/v/f:SI 4 %r4 [orig:29 s ] [29]))
>                 (const_int 4 [0x4])) [1 MEM[(int *)s_8(D) + 4B + _5 * 4]+0 S4 A32])) "pr58901-0.c":15:12 12 {movsi_2}
>      (nil))
> (insn 15 37 16 4 (set (reg:SI 2 %r2 [31])
>         (ashift:SI (const_int 1 [0x1])
>             (reg:QI 5 %r5))) "pr58901-0.c":15:12 94 {ashlsi3}
>      (nil))
>
> and assembly like:
>
> .L3:
> 	movl 4(%r4)[%r1],%r5
> 	ashl %r5,$1,%r2
> 	xorl2 %r2,%r0
> 	incl %r1
> 	cmpl %r1,%r3
> 	jneq .L3
>
> produced for the loop, providing optimization has been enabled.  
>
> Likewise with test case #1 the reload of:
>
> (insn 17 16 18 4 (set (reg:SI 34)
>         (and:SI (subreg:SI (reg/v:DI 27 [ t ]) 4)
>             (const_int 1 [0x1]))) "pr58901-1.c":18:20 77 {*andsi_const_int}
>      (expr_list:REG_DEAD (reg/v:DI 27 [ t ])
>         (nil)))
>
> is as follows:
>
> Reloads for insn # 17
> Reload 0: reload_in (DI) = (reg/v:DI 27 [ t ])
> 	reload_out (SI) = (reg:SI 2 %r2 [34])
> 	ALL_REGS, RELOAD_OTHER (opnum = 0)
> 	reload_in_reg: (reg/v:DI 27 [ t ])
> 	reload_out_reg: (reg:SI 2 %r2 [34])
> 	reload_reg_rtx: (reg:DI 4 %r4)
>
> resulting in:
>
> (insn 40 16 17 4 (set (reg:DI 4 %r4)
>         (mem/c:DI (plus:SI (mult:SI (reg/v:SI 1 %r1 [orig:26 i ] [26])
>                     (const_int 8 [0x8]))
>                 (reg/v/f:SI 3 %r3 [orig:30 s ] [30])) [1 MEM[(const struct s *)s_13(D) + _7 * 8]+0 S8 A32])) "pr58901-1.c":18:20 11 {movdi}
>      (nil))
> (insn 17 40 41 4 (set (reg:SI 4 %r4)
>         (and:SI (reg:SI 5 %r5 [+4 ])
>             (const_int 1 [0x1]))) "pr58901-1.c":18:20 77 {*andsi_const_int}
>      (nil))
>
> and assembly like:
>
> .L3:
> 	movq (%r3)[%r1],%r4
> 	bicl3 $-2,%r5,%r4
> 	addl2 %r4,%r0
> 	jaoblss %r0,%r1,.L3
>
> First posted at: <https://gcc.gnu.org/ml/gcc/2014-06/msg00060.html>.
>
> 2020-11-27  Matt Thomas  <matt@3am-software.com>
> 	    Maciej W. Rozycki  <macro@linux-mips.org>
>
> 	gcc/
> 	PR target/58901
> 	* reload.c (push_reload): Also reload the inner expression of a 
> 	SUBREG for pseudos associated with a mode-dependent memory 
> 	reference.
> 	(find_reloads): Force a reload likewise.
>
> 2020-11-27  Maciej W. Rozycki  <macro@linux-mips.org>
>
> 	gcc/testsuite/
> 	PR target/58901
> 	* gcc.c-torture/compile/pr58901-0.c: New test.
> 	* gcc.c-torture/compile/pr58901-1.c: New test.
So one could make the argument that the (subreg (mem)) should never have
been generated in the first place.   I'm guessing they ultimately stem
from using QImode for the shift count.

The mode for the shift count has always been a bit controversial.  
We've got some ports that use QImode similar to the vax and others that
use the target's most natural mode, even if it's wider than what the
target really needs.  I can't offhand recall if there was a general
consensus on the best way for a target to handle this.

I'm certain there's other problems in the reloading of mode dependent
addresses.  See 66087 on the m68k.  This patch doesn't address that
issue (I was hoping it would, but such is life).  I'm not too inclined
to have folks chasing these issues though as reload (IMHO) should be on
the chopping block for gcc-12.

My overall thought WRT this patch is similar to Ulrich's.  Let's go with
it even though we know it's not necessarily 100% complete.  We can have
(subreg (mem)) coming into reload as say from 66087.  We may have other
ways where reload replaces a pseudo with a mem that aren't necessarily
caught here.

Jeff


  reply	other threads:[~2020-11-30 18:51 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20  3:38 [PATCH 00/31] VAX: Bring the port up to date (yes, MODE_CC conversion is included) Maciej W. Rozycki
2020-11-20  3:34 ` [PATCH 01/31] PR target/58901: reload: Handle SUBREG of MEM with a mode-dependent address Maciej W. Rozycki
2020-11-20 10:55   ` Eric Botcazou
2020-11-20 15:30     ` Maciej W. Rozycki
2020-11-24  6:19       ` [PATCH v2 " Maciej W. Rozycki
2020-11-24 11:03         ` Eric Botcazou
2020-11-26 17:22           ` Maciej W. Rozycki
2020-11-27  3:51             ` Maciej W. Rozycki
2020-11-27 10:52         ` Ulrich Weigand
2020-11-27 19:22           ` Maciej W. Rozycki
2020-11-27 20:47             ` Maciej W. Rozycki
2020-11-27 20:50               ` [PATCH v3 " Maciej W. Rozycki
2020-11-30 18:51                 ` Jeff Law [this message]
2020-11-29 17:31             ` [PATCH v2 " Jeff Law
2020-11-20  3:34 ` [PATCH 02/31] VAX: Remove `c' operand format specifier overload Maciej W. Rozycki
2020-11-20 23:16   ` Jeff Law
2020-11-24  1:12   ` Segher Boessenkool
2020-11-20  3:34 ` [PATCH 03/31] VAX: Define LEGITIMATE_PIC_OPERAND_P Maciej W. Rozycki
2020-11-21  3:17   ` Jeff Law
2020-11-20  3:34 ` [PATCH 04/31] VAX/testsuite: Run target testing over all the usual optimization levels Maciej W. Rozycki
2020-11-20 23:17   ` Jeff Law
2020-11-20  3:34 ` [PATCH 05/31] VAX: Rationalize expression and address costs Maciej W. Rozycki
2020-11-21  3:48   ` Jeff Law
2020-11-20  3:34 ` [PATCH 06/31] VAX: Correct fatal issues with the `ffs' builtin Maciej W. Rozycki
2020-11-20 23:19   ` Jeff Law
2020-11-20  3:34 ` [PATCH 07/31] RTL: Also support HOST_WIDE_INT with int iterators Maciej W. Rozycki
2020-11-21  4:19   ` Jeff Law
2020-11-20  3:34 ` [PATCH 08/31] jump: Also handle jumps wrapped in UNSPEC or UNSPEC_VOLATILE Maciej W. Rozycki
2020-11-21  4:25   ` Jeff Law
2020-12-03  3:50     ` [PATCH v2 " Maciej W. Rozycki
2020-12-03 22:20       ` Jeff Law
2020-11-20  3:34 ` [PATCH 09/31] VAX: Use a mode iterator to produce individual interlocked branches Maciej W. Rozycki
2020-11-20 23:20   ` Jeff Law
2020-11-20  3:34 ` [PATCH 10/31] VAX: Use an int " Maciej W. Rozycki
2020-11-20 23:20   ` Jeff Law
2020-11-20  3:35 ` [PATCH 11/31] VAX: Correct `sync_lock_test_and_set' and `sync_lock_release' builtins Maciej W. Rozycki
2020-11-21  4:26   ` Jeff Law
2020-11-20  3:35 ` [PATCH 12/31] VAX: Actually enable `builtins.md' now that it is fully functional Maciej W. Rozycki
2020-11-20 23:21   ` Jeff Law
2020-11-20  3:35 ` [PATCH 13/31] VAX: Add a test for the SImode `ffs' operation Maciej W. Rozycki
2020-11-20 23:22   ` Jeff Law
2020-11-20  3:35 ` [PATCH 14/31] VAX: Add tests for `sync_lock_test_and_set' and `sync_lock_release' Maciej W. Rozycki
2020-11-20 23:22   ` Jeff Law
2020-11-20  3:35 ` [PATCH 15/31] VAX: Provide the `ctz' operation Maciej W. Rozycki
2020-11-20 23:23   ` Jeff Law
2020-11-20  3:35 ` [PATCH 16/31] VAX: Also provide QImode and HImode `ctz' and `ffs' operations Maciej W. Rozycki
2020-11-20 23:24   ` Jeff Law
2020-11-20  3:35 ` [PATCH 17/31] VAX: Actually produce QImode and HImode `ctz' operations Maciej W. Rozycki
2020-11-20 23:24   ` Jeff Law
2020-11-20  3:35 ` [PATCH 18/31] VAX: Add a test for the `cpymemhi' instruction Maciej W. Rozycki
2020-11-20 23:25   ` Jeff Law
2020-11-20  3:35 ` [PATCH 19/31] VAX: Add the `movmemhi' instruction Maciej W. Rozycki
2020-11-20 23:25   ` Jeff Law
2020-11-20  3:35 ` [PATCH 20/31] VAX: Fix predicates and constraints for EXTV/EXTZV/INSV insns Maciej W. Rozycki
2020-11-21 17:01   ` Jeff Law
2020-11-20  3:35 ` [PATCH 21/31] VAX: Remove EXTV/EXTZV/INSV instruction use from aligned case insns Maciej W. Rozycki
2020-11-21 17:25   ` Jeff Law
2020-11-20  3:35 ` [PATCH 22/31] VAX: Ensure PIC mode address is adjustable with aligned bitfield insns Maciej W. Rozycki
2020-11-21 17:03   ` Jeff Law
2020-11-20  3:36 ` [PATCH 23/31] VAX: Make `extv' an expander matching the remaining bitfield operations Maciej W. Rozycki
2020-11-21 17:26   ` Jeff Law
2020-11-20  3:36 ` [PATCH 24/31] VAX: Fix predicates and constraints for bitfield comparison insns Maciej W. Rozycki
2020-11-21 17:27   ` Jeff Law
2020-11-20  3:36 ` [PATCH 25/31] VAX: Fix predicates for widening multiply and multiply-add insns Maciej W. Rozycki
2020-11-21  4:05   ` Jeff Law
2020-11-30 16:02     ` Maciej W. Rozycki
2020-11-30 18:29       ` Jeff Law
2020-11-20  3:36 ` [PATCH 26/31] VAX: Correct issues with commented-out insns Maciej W. Rozycki
2020-11-21  4:05   ` Jeff Law
2020-11-20  3:36 ` [PATCH 27/31] VAX: Make the `divmoddisi4' and `*amulsi4' comment notation consistent Maciej W. Rozycki
2020-11-21  4:06   ` Jeff Law
2020-11-24  1:37   ` Segher Boessenkool
2020-11-20  3:36 ` [PATCH 28/31] RTL: Add `const_double_zero' syntactic rtx Maciej W. Rozycki
2020-11-21 17:29   ` Jeff Law
2020-11-20  3:36 ` [PATCH 29/31] PDP11: Use `const_double_zero' to express double zero constant Maciej W. Rozycki
2020-11-21  4:07   ` Jeff Law
2020-12-15  8:26   ` Martin Liška
2020-12-15 14:06     ` Maciej W. Rozycki
2020-12-15 18:02       ` Paul Koning
2020-12-15 18:38         ` Maciej W. Rozycki
2020-11-20  3:36 ` [PATCH 30/31] PR target/95294: VAX: Convert backend to MODE_CC representation Maciej W. Rozycki
2020-11-22  3:27   ` Jeff Law
2020-12-09 16:09   ` Maciej W. Rozycki
2020-11-20  3:37 ` [PATCH 31/31] PR target/95294: VAX: Add test cases for " Maciej W. Rozycki
2020-11-21  4:08   ` Jeff Law
2020-12-05 18:40     ` Maciej W. Rozycki
2020-11-20  7:58 ` [PATCH 00/31] VAX: Bring the port up to date (yes, MODE_CC conversion is included) Anders Magnusson
2020-11-23 20:31   ` Maciej W. Rozycki
2020-11-21 21:02 ` Toon Moene
2020-11-23 21:51   ` Maciej W. Rozycki
2020-11-23 22:12     ` Thomas Koenig
2020-11-24  4:28       ` Maciej W. Rozycki
2020-11-24  5:27         ` Maciej W. Rozycki
2020-11-24  6:04           ` Maciej W. Rozycki
2020-11-24  6:16             ` Thomas Koenig
2020-11-25 19:22               ` Maciej W. Rozycki
2020-11-25 18:26             ` Maciej W. Rozycki
2020-11-25 22:20               ` Joseph Myers
2020-11-26 18:01                 ` Maciej W. Rozycki
2020-11-26 18:08                   ` Martin Husemann
2020-12-08 14:38                     ` Maciej W. Rozycki
2020-12-08 15:22                       ` Martin Husemann
2020-11-25 22:26           ` coypu
2020-11-26 17:59             ` Maciej W. Rozycki
2020-11-26 19:35               ` Maciej W. Rozycki
2020-11-23 15:48 ` Paul Koning
2020-11-25 17:07   ` Maciej W. Rozycki
2020-11-28 18:48     ` Paul Koning
2020-12-09 14:06       ` Maciej W. Rozycki
2020-12-10  1:33         ` Paul Koning
2020-12-11 14:54           ` Maciej W. Rozycki
2020-12-11 21:50             ` Paul Koning
2020-11-25 18:36 ` Maciej W. Rozycki
2020-11-26 14:46   ` Ian Lance Taylor
2020-11-26 18:07     ` Maciej W. Rozycki
2020-11-29 17:56   ` Martin Sebor
2020-12-07 14:25     ` Maciej W. Rozycki

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=8837efc1-32fa-6899-220c-0a8f5e0ad154@redhat.com \
    --to=law@redhat.com \
    --cc=botcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=macro@linux-mips.org \
    --cc=ragge@tethuvudet.se \
    --cc=uweigand@de.ibm.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).