* [PATCH] testsuite: Fix up lra effective target @ 2024-02-16 10:16 Jakub Jelinek 2024-02-16 18:43 ` Mike Stump ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Jakub Jelinek @ 2024-02-16 10:16 UTC (permalink / raw) To: Richard Biener, Rainer Orth, Mike Stump, Thomas Schwinge; +Cc: gcc-patches Hi! Given the recent discussions on IRC started with Andrew P. mentioning that an asm goto outputs test should have { target lra } and the lra effective target in GCC 11/12 only returning 0 for PA and in 13/14 for PA/AVR, while we clearly have 14 other targets which don't support LRA and a couple of further ones which have an -mlra/-mno-lra switch (whatever default they have), seems to me the effective target is quite broken. The following patch rewrites it, such that it has a fast path for heavily used targets which are for years known to use only LRA (just an optimization) plus determines whether it is a LRA target or reload target by scanning the -fdump-rtl-reload-details dump on an empty function, LRA has quite a few always emitted messages in that case while reload has none of those. Tested on x86_64-linux and cross to s390x-linux, for the latter with both make check-gcc RUNTESTFLAGS='--target_board=unix/-mno-lra dg.exp=pr107385.c' where the test is now UNSUPPORTED and make check-gcc RUNTESTFLAGS='--target_board=unix/-mlra dg.exp=pr107385.c' where it fails because I don't have libc around. Ok for trunk? There is one special case, NVPTX, which is a TARGET_NO_REGISTER_ALLOCATION target. I think claiming for it that it is a lra target is strange (even though it effectively returns true for targetm.lra_p ()), unsure if it supports asm goto with outputs or not, if it does and we want to test it, perhaps we should introduce asm_goto_outputs effective target and use lra || nvptx-*-* for that? 2024-02-16 Jakub Jelinek <jakub@redhat.com> * lib/target-supports.exp (check_effective_target_lra): Rewrite to list some heavily used always LRA targets and otherwise check the -fdump-rtl-reload-details dump for messages specific to LRA. --- gcc/testsuite/lib/target-supports.exp.jj 2024-02-15 09:51:34.591064180 +0100 +++ gcc/testsuite/lib/target-supports.exp 2024-02-16 10:50:29.986180603 +0100 @@ -13215,10 +13215,17 @@ proc check_effective_target_powerpc_as_p # return 1 if LRA is supported. proc check_effective_target_lra { } { - if { [istarget hppa*-*-*] || [istarget avr-*-*] } { - return 0 + # Start with heavily used targets which are known to always use LRA. + if { [istarget i?86-*-*] || [istarget x86_64-*-*] + || [istarget aarch64*-*-*] || [istarget arm*-*-*] + || [istarget powerpc*-*-*] || [istarget riscv*-*-*] } { + return 1 } - return 1 + + # Otherwise check the reload dump for messages emitted solely by LRA. + return [check_no_messages_and_pattern lra "\\\*{9} Local #1: \\\*{9}" rtl-reload { + void foo (void) {} + } {-O2 -fdump-rtl-reload-details}] ;# LRA notes requires a detailed dump. } # Test whether optimizations are enabled ('__OPTIMIZE__') per the Jakub ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] testsuite: Fix up lra effective target 2024-02-16 10:16 [PATCH] testsuite: Fix up lra effective target Jakub Jelinek @ 2024-02-16 18:43 ` Mike Stump 2024-02-16 18:48 ` Mike Stump 2024-02-26 2:10 ` [PATCH] testsuite: Fix up lra effective target Hans-Peter Nilsson 2 siblings, 0 replies; 9+ messages in thread From: Mike Stump @ 2024-02-16 18:43 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Richard Biener, Rainer Orth, Thomas Schwinge, gcc-patches On Feb 16, 2024, at 2:16 AM, Jakub Jelinek <jakub@redhat.com> wrote: > > Given the recent discussions on IRC started with Andrew P. mentioning that > an asm goto outputs test should have { target lra } and the lra effective > target in GCC 11/12 only returning 0 for PA and in 13/14 for PA/AVR, while > we clearly have 14 other targets which don't support LRA and a couple of > further ones which have an -mlra/-mno-lra switch (whatever default they > have), seems to me the effective target is quite broken. > > Ok for trunk? Ok. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] testsuite: Fix up lra effective target 2024-02-16 10:16 [PATCH] testsuite: Fix up lra effective target Jakub Jelinek 2024-02-16 18:43 ` Mike Stump @ 2024-02-16 18:48 ` Mike Stump 2024-03-21 11:20 ` New effective-target 'asm_goto_with_outputs' (was: [PATCH] testsuite: Fix up lra effective target) Thomas Schwinge 2024-02-26 2:10 ` [PATCH] testsuite: Fix up lra effective target Hans-Peter Nilsson 2 siblings, 1 reply; 9+ messages in thread From: Mike Stump @ 2024-02-16 18:48 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Richard Biener, Rainer Orth, Thomas Schwinge, gcc-patches On Feb 16, 2024, at 2:16 AM, Jakub Jelinek <jakub@redhat.com> wrote: > > There is one special case, NVPTX, which is a TARGET_NO_REGISTER_ALLOCATION > target. I think claiming for it that it is a lra target is strange (even > though it effectively returns true for targetm.lra_p ()), unsure if it > supports asm goto with outputs or not, if it does and we want to test it, > perhaps we should introduce asm_goto_outputs effective target and use > lra || nvptx-*-* for that? Since the port people have to maintain that code in general, I usually leave it to them to try and select a cheap, maintainable way to manage it. If people want to pave the way, I'd tend to defer to them, having thought about more than I. ^ permalink raw reply [flat|nested] 9+ messages in thread
* New effective-target 'asm_goto_with_outputs' (was: [PATCH] testsuite: Fix up lra effective target) 2024-02-16 18:48 ` Mike Stump @ 2024-03-21 11:20 ` Thomas Schwinge 2024-03-22 18:17 ` New effective-target 'asm_goto_with_outputs' Jeff Law 2024-04-08 20:13 ` New effective-target 'asm_goto_with_outputs' (was: [PATCH] testsuite: Fix up lra effective target) Thomas Schwinge 0 siblings, 2 replies; 9+ messages in thread From: Thomas Schwinge @ 2024-03-21 11:20 UTC (permalink / raw) To: Mike Stump, Jakub Jelinek, gcc-patches; +Cc: Richard Biener, Rainer Orth [-- Attachment #1: Type: text/plain, Size: 2652 bytes --] Hi! On 2024-02-16T10:48:53-0800, Mike Stump <mikestump@comcast.net> wrote: > On Feb 16, 2024, at 2:16 AM, Jakub Jelinek <jakub@redhat.com> wrote: >> >> There is one special case, NVPTX, which is a TARGET_NO_REGISTER_ALLOCATION >> target. I think claiming for it that it is a lra target is strange (even >> though it effectively returns true for targetm.lra_p ()), unsure if it >> supports asm goto with outputs or not, if it does and we want to test it, >> perhaps we should introduce asm_goto_outputs effective target and use >> lra || nvptx-*-* for that? > > Since the port people have to maintain that code in general, I usually leave it to them to try and select a cheap, maintainable way to manage it. > > If people want to pave the way, I'd tend to defer to them, having thought about more than I. Here I am. ;-) After commit e16f90be2dc8af6c371fe79044c3e668fa3dda62 "testsuite: Fix up lra effective target", we get for nvptx target: -PASS: gcc.c-torture/compile/asmgoto-2.c -O0 (test for excess errors) +ERROR: gcc.c-torture/compile/asmgoto-2.c -O0 : no files matched glob pattern "lra1020113.c.[0-9][0-9][0-9]r.reload" for " dg-do 2 compile { target lra } " Etc. That is, the current effective-target 'lra' is not suitable for nvptx -- which, I suppose, is OK, given that nvptx neither uses LRA nor doesn't use LRA. ;-) (Therefore, effective-target 'lra' shouldn't get used in test cases that are active for nvptx.) However, nvptx appears to support 'asm goto' with outputs, including the new execution test case: PASS: gcc.dg/pr107385.c execution test I'm attaching "[WIP] New effective-target 'asm_goto_with_outputs'", which does address the effective-target check for nvptx, and otherwise does 's%lra%asm_goto_with_outputs'. (I have not yet actually merged 'check_effective_target_lra' into 'check_effective_target_asm_goto_with_outputs'.) I have verified that all current effective-target 'lra' test cases actually use 'asm goto' with outputs, there is just one exception: 'gcc.dg/pr110079.c' (see <https://inbox.sourceware.org/Zel5TMMr/3BHgl0g@tucnak> "bb-reorder: Fix -freorder-blocks-and-partition ICEs on aarch64 with asm goto [PR110079]", <https://gcc.gnu.org/PR110079> "ICE with -freorder-blocks-and-partition and inline-asm goto"). That test case, 'gcc.dg/pr110079.c', currently uses 'target lra', and uses 'asm goto' -- but not with outputs, so is 'asm_goto_with_outputs' not really applicable? The test case does PASS for nvptx target (but I've not verified what it's actually doing/testing). How to handle that one? Grüße Thomas [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-WIP-New-effective-target-asm_goto_with_outputs.patch --] [-- Type: text/x-diff, Size: 8592 bytes --] From d9f8faaa5026bb970b3246235eb22bf9b5e9fe3a Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tschwinge@baylibre.com> Date: Mon, 4 Mar 2024 16:04:11 +0100 Subject: [PATCH] [WIP] New effective-target 'asm_goto_with_outputs' After commit e16f90be2dc8af6c371fe79044c3e668fa3dda62 "testsuite: Fix up lra effective target", we get for nvptx target: -PASS: gcc.c-torture/compile/asmgoto-2.c -O0 (test for excess errors) +ERROR: gcc.c-torture/compile/asmgoto-2.c -O0 : no files matched glob pattern "lra1020113.c.[0-9][0-9][0-9]r.reload" for " dg-do 2 compile { target lra } " Etc. However, nvptx appears to support 'asm goto' with outputs, including the new execution test case: PASS: gcc.dg/pr107385.c execution test TODO gcc/testsuite/gcc.dg/pr110079.c doesn't using 'asm_goto' with outputs, but is PASS for nvptx, and would ERROR for 'target lra'. --- gcc/doc/sourcebuild.texi | 3 +++ gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c | 2 +- gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c | 2 +- gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c | 3 +-- gcc/testsuite/gcc.c-torture/compile/pr98096.c | 2 +- gcc/testsuite/gcc.dg/pr100590.c | 2 +- gcc/testsuite/gcc.dg/pr107385.c | 2 +- gcc/testsuite/gcc.dg/pr108095.c | 2 +- gcc/testsuite/gcc.dg/pr110079.c | 2 +- gcc/testsuite/gcc.dg/pr97954.c | 2 +- gcc/testsuite/gcc.dg/torture/pr100329.c | 2 +- gcc/testsuite/gcc.dg/torture/pr100398.c | 2 +- gcc/testsuite/gcc.dg/torture/pr100519.c | 2 +- gcc/testsuite/gcc.dg/torture/pr110422.c | 2 +- gcc/testsuite/lib/target-supports.exp | 9 +++++++++ 15 files changed, 25 insertions(+), 14 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index b56b9c39733..a176a3c864f 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2863,6 +2863,9 @@ Target supports weak undefined symbols @item R_flag_in_section Target supports the 'R' flag in .section directive in assembly inputs. +@item asm_goto_with_outputs +Target supports 'asm goto' with outputs. + @item automatic_stack_alignment Target supports automatic stack alignment. diff --git a/gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c b/gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c index 43e597bc59f..234c90e5295 100644 --- a/gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c +++ b/gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c @@ -1,5 +1,5 @@ /* This test should be switched off for a new target with less than 4 allocatable registers */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ int foo (void) { diff --git a/gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c b/gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c index e1574a2903a..af1ba5a7001 100644 --- a/gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c +++ b/gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c @@ -1,5 +1,5 @@ /* Test to generate output reload in asm goto on x86_64. */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-skip-if "no O0" { { i?86-*-* x86_64-*-* } && { ! ia32 } } { "-O0" } { "" } } */ #if defined __x86_64__ diff --git a/gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c b/gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c index 6799b83c20a..cb3c7d711a6 100644 --- a/gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c +++ b/gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c @@ -1,5 +1,4 @@ - -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* PR middle-end/110420 */ /* PR middle-end/103979 */ /* PR middle-end/98619 */ diff --git a/gcc/testsuite/gcc.c-torture/compile/pr98096.c b/gcc/testsuite/gcc.c-torture/compile/pr98096.c index bba3fa5c619..3a1b6159c2e 100644 --- a/gcc/testsuite/gcc.c-torture/compile/pr98096.c +++ b/gcc/testsuite/gcc.c-torture/compile/pr98096.c @@ -1,6 +1,6 @@ /* Test for correct naming of label operands in asm goto in case of presence of input/output operands. */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ int i, j; int f(void) { asm goto ("# %0 %2" : "+r" (i) ::: jmp); diff --git a/gcc/testsuite/gcc.dg/pr100590.c b/gcc/testsuite/gcc.dg/pr100590.c index 8d1e1a0d306..64cb717ed0e 100644 --- a/gcc/testsuite/gcc.dg/pr100590.c +++ b/gcc/testsuite/gcc.dg/pr100590.c @@ -1,5 +1,5 @@ /* PR rtl-optimization/100590 */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-options "-O1 -fno-dce -w" } */ int diff --git a/gcc/testsuite/gcc.dg/pr107385.c b/gcc/testsuite/gcc.dg/pr107385.c index 0cc0655d848..690ad3c1b5e 100644 --- a/gcc/testsuite/gcc.dg/pr107385.c +++ b/gcc/testsuite/gcc.dg/pr107385.c @@ -1,5 +1,5 @@ /* PR middle-end/107385 */ -/* { dg-do run { target lra } } */ +/* { dg-do run { target asm_goto_with_outputs } } */ /* { dg-options "-O2" } */ __attribute__((noipa)) int diff --git a/gcc/testsuite/gcc.dg/pr108095.c b/gcc/testsuite/gcc.dg/pr108095.c index 0a487cf614a..115ea73e39b 100644 --- a/gcc/testsuite/gcc.dg/pr108095.c +++ b/gcc/testsuite/gcc.dg/pr108095.c @@ -1,5 +1,5 @@ /* PR tree-optimization/108095 */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-options "-Os -g" } */ int v; diff --git a/gcc/testsuite/gcc.dg/pr110079.c b/gcc/testsuite/gcc.dg/pr110079.c index 1682f9c2344..e8ec6666b23 100644 --- a/gcc/testsuite/gcc.dg/pr110079.c +++ b/gcc/testsuite/gcc.dg/pr110079.c @@ -1,5 +1,5 @@ /* PR rtl-optimization/110079 */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-options "-O2" } */ /* { dg-additional-options "-freorder-blocks-and-partition" { target freorder } } */ diff --git a/gcc/testsuite/gcc.dg/pr97954.c b/gcc/testsuite/gcc.dg/pr97954.c index 0be60f500b6..619bed3b40c 100644 --- a/gcc/testsuite/gcc.dg/pr97954.c +++ b/gcc/testsuite/gcc.dg/pr97954.c @@ -1,5 +1,5 @@ /* PR rtl-optimization/97954 */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-options "-O2" } */ int diff --git a/gcc/testsuite/gcc.dg/torture/pr100329.c b/gcc/testsuite/gcc.dg/torture/pr100329.c index 2a4331ba712..5759131a6ca 100644 --- a/gcc/testsuite/gcc.dg/torture/pr100329.c +++ b/gcc/testsuite/gcc.dg/torture/pr100329.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-additional-options "--param tree-reassoc-width=2" } */ unsigned int a0; diff --git a/gcc/testsuite/gcc.dg/torture/pr100398.c b/gcc/testsuite/gcc.dg/torture/pr100398.c index 4fc1168d22f..eeeaf98e15b 100644 --- a/gcc/testsuite/gcc.dg/torture/pr100398.c +++ b/gcc/testsuite/gcc.dg/torture/pr100398.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ int test5_limit (void) diff --git a/gcc/testsuite/gcc.dg/torture/pr100519.c b/gcc/testsuite/gcc.dg/torture/pr100519.c index 89dff668a97..b82ce46c529 100644 --- a/gcc/testsuite/gcc.dg/torture/pr100519.c +++ b/gcc/testsuite/gcc.dg/torture/pr100519.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-additional-options "--param tree-reassoc-width=2" } */ unsigned int foo_a1, foo_a2; diff --git a/gcc/testsuite/gcc.dg/torture/pr110422.c b/gcc/testsuite/gcc.dg/torture/pr110422.c index 2a653bdfce3..34de7a2980f 100644 --- a/gcc/testsuite/gcc.dg/torture/pr110422.c +++ b/gcc/testsuite/gcc.dg/torture/pr110422.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ struct T { int x; }; int foo(void) { diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 5a1f0ed5a28..158dc51a71f 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -13211,6 +13211,15 @@ proc check_effective_target_lra { } { } {-O2 -fdump-rtl-reload-details}] ;# LRA notes requires a detailed dump. } +# Return 1 if 'asm goto' with outputs is supported, 0 otherwise. + +proc check_effective_target_asm_goto_with_outputs { } { + if { [istarget nvptx-*-*] } { + return 1 + } + return [check_effective_target_lra] +} + # Test whether optimizations are enabled ('__OPTIMIZE__') per the # 'current_compiler_flags' (thus don't cache). -- 2.34.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: New effective-target 'asm_goto_with_outputs' 2024-03-21 11:20 ` New effective-target 'asm_goto_with_outputs' (was: [PATCH] testsuite: Fix up lra effective target) Thomas Schwinge @ 2024-03-22 18:17 ` Jeff Law 2024-03-22 18:24 ` Jakub Jelinek 2024-04-08 20:13 ` New effective-target 'asm_goto_with_outputs' (was: [PATCH] testsuite: Fix up lra effective target) Thomas Schwinge 1 sibling, 1 reply; 9+ messages in thread From: Jeff Law @ 2024-03-22 18:17 UTC (permalink / raw) To: Thomas Schwinge, Mike Stump, Jakub Jelinek, gcc-patches Cc: Richard Biener, Rainer Orth On 3/21/24 5:20 AM, Thomas Schwinge wrote: > Hi! > > On 2024-02-16T10:48:53-0800, Mike Stump <mikestump@comcast.net> wrote: >> On Feb 16, 2024, at 2:16 AM, Jakub Jelinek <jakub@redhat.com> wrote: >>> >>> There is one special case, NVPTX, which is a TARGET_NO_REGISTER_ALLOCATION >>> target. I think claiming for it that it is a lra target is strange (even >>> though it effectively returns true for targetm.lra_p ()), unsure if it >>> supports asm goto with outputs or not, if it does and we want to test it, >>> perhaps we should introduce asm_goto_outputs effective target and use >>> lra || nvptx-*-* for that? >> >> Since the port people have to maintain that code in general, I usually leave it to them to try and select a cheap, maintainable way to manage it. >> >> If people want to pave the way, I'd tend to defer to them, having thought about more than I. > > Here I am. ;-) > > After commit e16f90be2dc8af6c371fe79044c3e668fa3dda62 > "testsuite: Fix up lra effective target", we get for nvptx target: > > -PASS: gcc.c-torture/compile/asmgoto-2.c -O0 (test for excess errors) > +ERROR: gcc.c-torture/compile/asmgoto-2.c -O0 : no files matched glob pattern "lra1020113.c.[0-9][0-9][0-9]r.reload" for " dg-do 2 compile { target lra } " > > Etc. > > That is, the current effective-target 'lra' is not suitable for nvptx -- > which, I suppose, is OK, given that nvptx neither uses LRA nor doesn't > use LRA. ;-) (Therefore, effective-target 'lra' shouldn't get used in > test cases that are active for nvptx.) > > However, nvptx appears to support 'asm goto' with outputs, including the > new execution test case: > > PASS: gcc.dg/pr107385.c execution test > > I'm attaching "[WIP] New effective-target 'asm_goto_with_outputs'", which > does address the effective-target check for nvptx, and otherwise does > 's%lra%asm_goto_with_outputs'. (I have not yet actually merged > 'check_effective_target_lra' into > 'check_effective_target_asm_goto_with_outputs'.) > > I have verified that all current effective-target 'lra' test cases > actually use 'asm goto' with outputs, there is just one exception: > 'gcc.dg/pr110079.c' (see > <https://inbox.sourceware.org/Zel5TMMr/3BHgl0g@tucnak> > "bb-reorder: Fix -freorder-blocks-and-partition ICEs on aarch64 with asm goto [PR110079]", > <https://gcc.gnu.org/PR110079> > "ICE with -freorder-blocks-and-partition and inline-asm goto"). That > test case, 'gcc.dg/pr110079.c', currently uses 'target lra', and uses > 'asm goto' -- but not with outputs, so is 'asm_goto_with_outputs' not > really applicable? The test case does PASS for nvptx target (but I've > not verified what it's actually doing/testing). How to handle that one? I'd just make target_lra return false for nvptx rather than creating a new selector -- I'm not aware of any features other than asm goto that LRA provides that aren't supported reload. Or perhaps rename the selector entirely to target_asm_goto? jeff ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: New effective-target 'asm_goto_with_outputs' 2024-03-22 18:17 ` New effective-target 'asm_goto_with_outputs' Jeff Law @ 2024-03-22 18:24 ` Jakub Jelinek 2024-03-22 18:55 ` Jeff Law 0 siblings, 1 reply; 9+ messages in thread From: Jakub Jelinek @ 2024-03-22 18:24 UTC (permalink / raw) To: Jeff Law Cc: Thomas Schwinge, Mike Stump, gcc-patches, Richard Biener, Rainer Orth On Fri, Mar 22, 2024 at 12:17:03PM -0600, Jeff Law wrote: > I'd just make target_lra return false for nvptx rather than creating a new The lra effective target currently though doesn't check if asm goto can have outputs, but rather if the target is using lra. > selector -- I'm not aware of any features other than asm goto that LRA > provides that aren't supported reload. > > Or perhaps rename the selector entirely to target_asm_goto? In that case we should just test if asm goto with outputs is allowed in a cached snippet, rather than testing if there is LRA in the ra dumps. Jakub ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: New effective-target 'asm_goto_with_outputs' 2024-03-22 18:24 ` Jakub Jelinek @ 2024-03-22 18:55 ` Jeff Law 0 siblings, 0 replies; 9+ messages in thread From: Jeff Law @ 2024-03-22 18:55 UTC (permalink / raw) To: Jakub Jelinek Cc: Thomas Schwinge, Mike Stump, gcc-patches, Richard Biener, Rainer Orth On 3/22/24 12:24 PM, Jakub Jelinek wrote: > On Fri, Mar 22, 2024 at 12:17:03PM -0600, Jeff Law wrote: >> I'd just make target_lra return false for nvptx rather than creating a new > > The lra effective target currently though doesn't check if asm goto can have > outputs, but rather if the target is using lra. Right. It's not 100% precise as we lose one testcase for nvptx. THat's a tradeoff I'd be willing to make. > >> selector -- I'm not aware of any features other than asm goto that LRA >> provides that aren't supported reload. >> >> Or perhaps rename the selector entirely to target_asm_goto? > > In that case we should just test if asm goto with outputs is allowed > in a cached snippet, rather than testing if there is LRA in the ra dumps. I won't lose any sleep with that approach, I just don't see that it adds a lot of value. jeff ^ permalink raw reply [flat|nested] 9+ messages in thread
* New effective-target 'asm_goto_with_outputs' (was: [PATCH] testsuite: Fix up lra effective target) 2024-03-21 11:20 ` New effective-target 'asm_goto_with_outputs' (was: [PATCH] testsuite: Fix up lra effective target) Thomas Schwinge 2024-03-22 18:17 ` New effective-target 'asm_goto_with_outputs' Jeff Law @ 2024-04-08 20:13 ` Thomas Schwinge 1 sibling, 0 replies; 9+ messages in thread From: Thomas Schwinge @ 2024-04-08 20:13 UTC (permalink / raw) To: gcc-patches Cc: Mike Stump, Jakub Jelinek, Richard Biener, Rainer Orth, Jeff Law [-- Attachment #1: Type: text/plain, Size: 2935 bytes --] Hi! On 2024-03-21T12:20:38+0100, I wrote: > On 2024-02-16T10:48:53-0800, Mike Stump <mikestump@comcast.net> wrote: >> On Feb 16, 2024, at 2:16 AM, Jakub Jelinek <jakub@redhat.com> wrote: >>> >>> There is one special case, NVPTX, which is a TARGET_NO_REGISTER_ALLOCATION >>> target. I think claiming for it that it is a lra target is strange (even >>> though it effectively returns true for targetm.lra_p ()), unsure if it >>> supports asm goto with outputs or not, if it does and we want to test it, >>> perhaps we should introduce asm_goto_outputs effective target and use >>> lra || nvptx-*-* for that? >> >> Since the port people have to maintain that code in general, I usually leave it to them to try and select a cheap, maintainable way to manage it. >> >> If people want to pave the way, I'd tend to defer to them, having thought about more than I. > > Here I am. ;-) > > After commit e16f90be2dc8af6c371fe79044c3e668fa3dda62 > "testsuite: Fix up lra effective target", we get for nvptx target: > > -PASS: gcc.c-torture/compile/asmgoto-2.c -O0 (test for excess errors) > +ERROR: gcc.c-torture/compile/asmgoto-2.c -O0 : no files matched glob pattern "lra1020113.c.[0-9][0-9][0-9]r.reload" for " dg-do 2 compile { target lra } " > > Etc. > > That is, the current effective-target 'lra' is not suitable for nvptx -- > which, I suppose, is OK, given that nvptx neither uses LRA nor doesn't > use LRA. ;-) (Therefore, effective-target 'lra' shouldn't get used in > test cases that are active for nvptx.) > > However, nvptx appears to support 'asm goto' with outputs, including the > new execution test case: > > PASS: gcc.dg/pr107385.c execution test > > I'm attaching "[WIP] New effective-target 'asm_goto_with_outputs'", which > does address the effective-target check for nvptx, and otherwise does > 's%lra%asm_goto_with_outputs'. (I have not yet actually merged > 'check_effective_target_lra' into > 'check_effective_target_asm_goto_with_outputs'.) > > I have verified that all current effective-target 'lra' test cases > actually use 'asm goto' with outputs, there is just one exception: > 'gcc.dg/pr110079.c' (see > <https://inbox.sourceware.org/Zel5TMMr/3BHgl0g@tucnak> > "bb-reorder: Fix -freorder-blocks-and-partition ICEs on aarch64 with asm goto [PR110079]", > <https://gcc.gnu.org/PR110079> > "ICE with -freorder-blocks-and-partition and inline-asm goto"). That > test case, 'gcc.dg/pr110079.c', currently uses 'target lra', and uses > 'asm goto' -- but not with outputs, so is 'asm_goto_with_outputs' not > really applicable? The test case does PASS for nvptx target (but I've > not verified what it's actually doing/testing). How to handle that one? I've now pushed a v2 version to trunk branch in commit 3fa8bff30ab58bd8b8018764d390ec2fcc8153bb "New effective-target 'asm_goto_with_outputs'", see attached. Grüße Thomas [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-New-effective-target-asm_goto_with_outputs.patch --] [-- Type: text/x-diff, Size: 10332 bytes --] From 3fa8bff30ab58bd8b8018764d390ec2fcc8153bb Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tschwinge@baylibre.com> Date: Mon, 4 Mar 2024 16:04:11 +0100 Subject: [PATCH] New effective-target 'asm_goto_with_outputs' After commit e16f90be2dc8af6c371fe79044c3e668fa3dda62 "testsuite: Fix up lra effective target", we get for nvptx target: -PASS: gcc.c-torture/compile/asmgoto-2.c -O0 (test for excess errors) +ERROR: gcc.c-torture/compile/asmgoto-2.c -O0 : no files matched glob pattern "lra1020113.c.[0-9][0-9][0-9]r.reload" for " dg-do 2 compile { target lra } " Etc. However, nvptx appears to support 'asm goto' with outputs, including the new execution test case: PASS: gcc.dg/pr107385.c execution test Therefore, generally use new effective-target 'asm_goto_with_outputs' instead of 'lra'. One exceptions is 'gcc.dg/pr110079.c', which doesn't use 'asm goto' with outputs, and continues using effective-target 'lra', with special-casing nvptx target, to avoid ERROR for 'lra'. gcc/ * doc/sourcebuild.texi (Effective-Target Keywords): Document 'asm_goto_with_outputs'. Add comment to 'lra'. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_lra): Add comment. (check_effective_target_asm_goto_with_outputs): New. * gcc.c-torture/compile/asmgoto-2.c: Use it. * gcc.c-torture/compile/asmgoto-5.c: Likewise. * gcc.c-torture/compile/asmgoto-6.c: Likewise. * gcc.c-torture/compile/pr98096.c: Likewise. * gcc.dg/pr100590.c: Likewise. * gcc.dg/pr107385.c: Likewise. * gcc.dg/pr108095.c: Likewise. * gcc.dg/pr97954.c: Likewise. * gcc.dg/torture/pr100329.c: Likewise. * gcc.dg/torture/pr100398.c: Likewise. * gcc.dg/torture/pr100519.c: Likewise. * gcc.dg/torture/pr110422.c: Likewise. * gcc.dg/pr110079.c: Special-case nvptx target. --- gcc/doc/sourcebuild.texi | 6 ++++++ gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c | 2 +- gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c | 2 +- gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c | 3 +-- gcc/testsuite/gcc.c-torture/compile/pr98096.c | 2 +- gcc/testsuite/gcc.dg/pr100590.c | 2 +- gcc/testsuite/gcc.dg/pr107385.c | 2 +- gcc/testsuite/gcc.dg/pr108095.c | 2 +- gcc/testsuite/gcc.dg/pr110079.c | 2 +- gcc/testsuite/gcc.dg/pr97954.c | 2 +- gcc/testsuite/gcc.dg/torture/pr100329.c | 2 +- gcc/testsuite/gcc.dg/torture/pr100398.c | 2 +- gcc/testsuite/gcc.dg/torture/pr100519.c | 2 +- gcc/testsuite/gcc.dg/torture/pr110422.c | 2 +- gcc/testsuite/lib/target-supports.exp | 13 ++++++++++++- 15 files changed, 31 insertions(+), 15 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 7ef82fc9b00..7c0df90e822 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2871,6 +2871,9 @@ Target supports weak undefined symbols @item R_flag_in_section Target supports the 'R' flag in .section directive in assembly inputs. +@item asm_goto_with_outputs +Target supports 'asm goto' with outputs. + @item automatic_stack_alignment Target supports automatic stack alignment. @@ -2945,6 +2948,9 @@ Target is using an LLVM assembler and/or linker, instead of GNU Binutils. @item lra Target supports local register allocator (LRA). +This must not be called (results in @code{ERROR}) for targets that +don't do register allocation, and therefore neither use nor don't use +LRA. @item lto Compiler has been configured to support link-time optimization (LTO). diff --git a/gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c b/gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c index 43e597bc59f..234c90e5295 100644 --- a/gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c +++ b/gcc/testsuite/gcc.c-torture/compile/asmgoto-2.c @@ -1,5 +1,5 @@ /* This test should be switched off for a new target with less than 4 allocatable registers */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ int foo (void) { diff --git a/gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c b/gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c index e1574a2903a..af1ba5a7001 100644 --- a/gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c +++ b/gcc/testsuite/gcc.c-torture/compile/asmgoto-5.c @@ -1,5 +1,5 @@ /* Test to generate output reload in asm goto on x86_64. */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-skip-if "no O0" { { i?86-*-* x86_64-*-* } && { ! ia32 } } { "-O0" } { "" } } */ #if defined __x86_64__ diff --git a/gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c b/gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c index 6799b83c20a..cb3c7d711a6 100644 --- a/gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c +++ b/gcc/testsuite/gcc.c-torture/compile/asmgoto-6.c @@ -1,5 +1,4 @@ - -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* PR middle-end/110420 */ /* PR middle-end/103979 */ /* PR middle-end/98619 */ diff --git a/gcc/testsuite/gcc.c-torture/compile/pr98096.c b/gcc/testsuite/gcc.c-torture/compile/pr98096.c index bba3fa5c619..3a1b6159c2e 100644 --- a/gcc/testsuite/gcc.c-torture/compile/pr98096.c +++ b/gcc/testsuite/gcc.c-torture/compile/pr98096.c @@ -1,6 +1,6 @@ /* Test for correct naming of label operands in asm goto in case of presence of input/output operands. */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ int i, j; int f(void) { asm goto ("# %0 %2" : "+r" (i) ::: jmp); diff --git a/gcc/testsuite/gcc.dg/pr100590.c b/gcc/testsuite/gcc.dg/pr100590.c index 8d1e1a0d306..64cb717ed0e 100644 --- a/gcc/testsuite/gcc.dg/pr100590.c +++ b/gcc/testsuite/gcc.dg/pr100590.c @@ -1,5 +1,5 @@ /* PR rtl-optimization/100590 */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-options "-O1 -fno-dce -w" } */ int diff --git a/gcc/testsuite/gcc.dg/pr107385.c b/gcc/testsuite/gcc.dg/pr107385.c index 0cc0655d848..690ad3c1b5e 100644 --- a/gcc/testsuite/gcc.dg/pr107385.c +++ b/gcc/testsuite/gcc.dg/pr107385.c @@ -1,5 +1,5 @@ /* PR middle-end/107385 */ -/* { dg-do run { target lra } } */ +/* { dg-do run { target asm_goto_with_outputs } } */ /* { dg-options "-O2" } */ __attribute__((noipa)) int diff --git a/gcc/testsuite/gcc.dg/pr108095.c b/gcc/testsuite/gcc.dg/pr108095.c index 0a487cf614a..115ea73e39b 100644 --- a/gcc/testsuite/gcc.dg/pr108095.c +++ b/gcc/testsuite/gcc.dg/pr108095.c @@ -1,5 +1,5 @@ /* PR tree-optimization/108095 */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-options "-Os -g" } */ int v; diff --git a/gcc/testsuite/gcc.dg/pr110079.c b/gcc/testsuite/gcc.dg/pr110079.c index 1682f9c2344..f87064d5f2c 100644 --- a/gcc/testsuite/gcc.dg/pr110079.c +++ b/gcc/testsuite/gcc.dg/pr110079.c @@ -1,5 +1,5 @@ /* PR rtl-optimization/110079 */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target { nvptx-*-* || lra } } } */ /* { dg-options "-O2" } */ /* { dg-additional-options "-freorder-blocks-and-partition" { target freorder } } */ diff --git a/gcc/testsuite/gcc.dg/pr97954.c b/gcc/testsuite/gcc.dg/pr97954.c index 0be60f500b6..619bed3b40c 100644 --- a/gcc/testsuite/gcc.dg/pr97954.c +++ b/gcc/testsuite/gcc.dg/pr97954.c @@ -1,5 +1,5 @@ /* PR rtl-optimization/97954 */ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-options "-O2" } */ int diff --git a/gcc/testsuite/gcc.dg/torture/pr100329.c b/gcc/testsuite/gcc.dg/torture/pr100329.c index 2a4331ba712..5759131a6ca 100644 --- a/gcc/testsuite/gcc.dg/torture/pr100329.c +++ b/gcc/testsuite/gcc.dg/torture/pr100329.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-additional-options "--param tree-reassoc-width=2" } */ unsigned int a0; diff --git a/gcc/testsuite/gcc.dg/torture/pr100398.c b/gcc/testsuite/gcc.dg/torture/pr100398.c index 4fc1168d22f..eeeaf98e15b 100644 --- a/gcc/testsuite/gcc.dg/torture/pr100398.c +++ b/gcc/testsuite/gcc.dg/torture/pr100398.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ int test5_limit (void) diff --git a/gcc/testsuite/gcc.dg/torture/pr100519.c b/gcc/testsuite/gcc.dg/torture/pr100519.c index 89dff668a97..b82ce46c529 100644 --- a/gcc/testsuite/gcc.dg/torture/pr100519.c +++ b/gcc/testsuite/gcc.dg/torture/pr100519.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ /* { dg-additional-options "--param tree-reassoc-width=2" } */ unsigned int foo_a1, foo_a2; diff --git a/gcc/testsuite/gcc.dg/torture/pr110422.c b/gcc/testsuite/gcc.dg/torture/pr110422.c index 2a653bdfce3..34de7a2980f 100644 --- a/gcc/testsuite/gcc.dg/torture/pr110422.c +++ b/gcc/testsuite/gcc.dg/torture/pr110422.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target lra } } */ +/* { dg-do compile { target asm_goto_with_outputs } } */ struct T { int x; }; int foo(void) { diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 45435586de2..49f2482686a 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -13204,7 +13204,9 @@ proc check_effective_target_powerpc_as_p10_htm { } { }] } -# return 1 if LRA is supported. +# Return 1 if LRA is supported. This must not be called (results in ERROR) for +# targets that don't do register allocation, and therefore neither use nor +# don't use LRA. proc check_effective_target_lra { } { # Start with heavily used targets which are known to always use LRA. @@ -13220,6 +13222,15 @@ proc check_effective_target_lra { } { } {-O2 -fdump-rtl-reload-details}] ;# LRA notes requires a detailed dump. } +# Return 1 if 'asm goto' with outputs is supported, 0 otherwise. + +proc check_effective_target_asm_goto_with_outputs { } { + if { [istarget nvptx-*-*] } { + return 1 + } + return [check_effective_target_lra] +} + # Test whether optimizations are enabled ('__OPTIMIZE__') per the # 'current_compiler_flags' (thus don't cache). -- 2.34.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] testsuite: Fix up lra effective target 2024-02-16 10:16 [PATCH] testsuite: Fix up lra effective target Jakub Jelinek 2024-02-16 18:43 ` Mike Stump 2024-02-16 18:48 ` Mike Stump @ 2024-02-26 2:10 ` Hans-Peter Nilsson 2 siblings, 0 replies; 9+ messages in thread From: Hans-Peter Nilsson @ 2024-02-26 2:10 UTC (permalink / raw) To: Jakub Jelinek; +Cc: rguenther, ro, mikestump, tschwinge, gcc-patches > Date: Fri, 16 Feb 2024 11:16:22 +0100 > From: Jakub Jelinek <jakub@redhat.com> > Given the recent discussions on IRC started with Andrew P. mentioning that > an asm goto outputs test should have { target lra } and the lra effective > target in GCC 11/12 only returning 0 for PA and in 13/14 for PA/AVR, while > we clearly have 14 other targets which don't support LRA and a couple of > further ones which have an -mlra/-mno-lra switch (whatever default they > have), seems to me the effective target is quite broken. Definitely, good riddance to that list. I suggested a little over a year ago to generalize check_effective_target_lra to get rid of that flawed target list but was effectively shut down with a review request that'd *keep* the faulty non-lra target list. :-( "https://gcc.gnu.org/pipermail/gcc-patches/2023-February/611531.html" TL;DR: I based LRA-ness on EBB being scanned in LRA but not for reload (same empty foo), i.e. matching the string "EBB 2 3". I don't know which method more stable, but that didn't require -O2 nor -fdump-rtl-reload-details. Having said that, I'm glad there's now a generic, working (non-target-list-dependent) effective_target lra. brgds, H-P ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-04-08 20:13 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-02-16 10:16 [PATCH] testsuite: Fix up lra effective target Jakub Jelinek 2024-02-16 18:43 ` Mike Stump 2024-02-16 18:48 ` Mike Stump 2024-03-21 11:20 ` New effective-target 'asm_goto_with_outputs' (was: [PATCH] testsuite: Fix up lra effective target) Thomas Schwinge 2024-03-22 18:17 ` New effective-target 'asm_goto_with_outputs' Jeff Law 2024-03-22 18:24 ` Jakub Jelinek 2024-03-22 18:55 ` Jeff Law 2024-04-08 20:13 ` New effective-target 'asm_goto_with_outputs' (was: [PATCH] testsuite: Fix up lra effective target) Thomas Schwinge 2024-02-26 2:10 ` [PATCH] testsuite: Fix up lra effective target Hans-Peter Nilsson
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).