public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] g++: Add require-effective-target to multi-input file testcase pr95401.cc
@ 2023-11-03  6:18 Patrick O'Neill
  2023-11-10  1:34 ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick O'Neill @ 2023-11-03  6:18 UTC (permalink / raw)
  To: gcc-patches; +Cc: jeffreyalaw, gnu-toolchain, Patrick O'Neill

On non-vector targets dejagnu attempts dg-do compile for pr95401.cc.
This produces a command like this:
g++ pr95401.cc pr95401a.cc -S -o pr95401.s

which isn't valid (gcc does not accept multiple input files when using
-S with -o).

This patch adds require-effective-target vect_int to avoid the case
where the testcase is invoked with dg-do compile.

gcc/testsuite/ChangeLog:

	* g++.dg/vect/pr95401.cc: Add require-effective-target vect_int.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
---
Tested using rv64gc & rv64gcv to make sure the testcase runs/doesn't
compile as expected.

Somewhat related/similar problem (running vector test on non-vector
target):
https://inbox.sourceware.org/gcc-patches/20231102190911.66763-1-patrick@rivosinc.com/T/#u
https://inbox.sourceware.org/gcc-patches/20231102234527.77231-1-patrick@rivosinc.com/T/#u

Ideally we would have a way to ban a dejagnu dg-do or an equivalent to
check_vect_support_and_set_flags that returns true/false based on
if it emits run/compile as the default dg-do command.
require-effective-target seems to be a reasonable alternative.
pr95401.cc and pr95401a.cc only use int variables and arrays.
---
 gcc/testsuite/g++.dg/vect/pr95401.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/g++.dg/vect/pr95401.cc b/gcc/testsuite/g++.dg/vect/pr95401.cc
index 6a56dab0957..6a1b65ff0e7 100644
--- a/gcc/testsuite/g++.dg/vect/pr95401.cc
+++ b/gcc/testsuite/g++.dg/vect/pr95401.cc
@@ -1,5 +1,6 @@
 // { dg-additional-options "-mavx2 -O3" { target avx2_runtime } }
 // { dg-additional-sources pr95401a.cc }
+// { dg-require-effective-target vect_int }
 
 extern int var_9;
 extern unsigned var_14;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] g++: Add require-effective-target to multi-input file testcase pr95401.cc
  2023-11-03  6:18 [PATCH] g++: Add require-effective-target to multi-input file testcase pr95401.cc Patrick O'Neill
@ 2023-11-10  1:34 ` Jeff Law
  2023-11-10 18:00   ` Patrick O'Neill
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2023-11-10  1:34 UTC (permalink / raw)
  To: Patrick O'Neill, gcc-patches; +Cc: gnu-toolchain



On 11/3/23 00:18, Patrick O'Neill wrote:
> On non-vector targets dejagnu attempts dg-do compile for pr95401.cc.
> This produces a command like this:
> g++ pr95401.cc pr95401a.cc -S -o pr95401.s
> 
> which isn't valid (gcc does not accept multiple input files when using
> -S with -o).
> 
> This patch adds require-effective-target vect_int to avoid the case
> where the testcase is invoked with dg-do compile.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/vect/pr95401.cc: Add require-effective-target vect_int.
Sorry, I must be missing something here.  I fail to see how adding an 
effective target check would/should impact the problem you've described 
above with the dg-additional-sources interaction with -S.

Jeff
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] g++: Add require-effective-target to multi-input file testcase pr95401.cc
  2023-11-10  1:34 ` Jeff Law
@ 2023-11-10 18:00   ` Patrick O'Neill
  2023-11-19  4:08     ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick O'Neill @ 2023-11-10 18:00 UTC (permalink / raw)
  To: Jeff Law, gcc-patches; +Cc: gnu-toolchain

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


On 11/9/23 17:34, Jeff Law wrote:
>
>
> On 11/3/23 00:18, Patrick O'Neill wrote:
>> On non-vector targets dejagnu attempts dg-do compile for pr95401.cc.
>> This produces a command like this:
>> g++ pr95401.cc pr95401a.cc -S -o pr95401.s
>>
>> which isn't valid (gcc does not accept multiple input files when using
>> -S with -o).
>>
>> This patch adds require-effective-target vect_int to avoid the case
>> where the testcase is invoked with dg-do compile.
>>
>> gcc/testsuite/ChangeLog:
>>
>>     * g++.dg/vect/pr95401.cc: Add require-effective-target vect_int.
> Sorry, I must be missing something here.  I fail to see how adding an 
> effective target check would/should impact the problem you've 
> described above with the dg-additional-sources interaction with -S.

It's not intuitive (& probably not the cleanest way of solving it).

pr95401.cc is an invalid testcase when run with dg-do compile (for the 
reasons above).

pr95401.cc 
<https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/g%2B%2B.dg/vect/pr95401.cc;h=6a56dab095722b01d912416352df17f0d91dfd27;hb=HEAD> 
does not define a dg-do, which means it uses the testcase uses 
dg-do-what-default 
<https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/g%2B%2B.dg/vect/vect.exp;h=fc77120a83173c65ad147e8bb7c29ac82f06bb6d;hb=HEAD#l30> 
to determine what to do.
dg-do-what-default is set by target-supports.exp 
<https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/lib/target-supports.exp;h=1a7bea96c1e4ccb8ef30ac7012c04e8d44c5ad01;hb=HEAD#l11532>.

The two options here are set dg-do-what-default run or compile.
On non-vector targets the pr95401 is set to compile (which is invalid).

Ideally we would say if dg-do-what-default == compile don't run, but 
AFAIK that isn't possible.
I didn't want to duplicate the check_vect_support_and_set_flags logic to 
return true/false since that'll probably get out of sync.

I used require-effective-target vect_int as a proxy for 
check_vect_support_and_set_flags (also since the testcase only contains 
integer arrays).

That way we do this now:
dg-do-what-default run -> run
dg-do-what-default compile -> skip test

If there's a cleaner/better approach I'm happy to revise.

Patrick

>
> Jeff
>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] g++: Add require-effective-target to multi-input file testcase pr95401.cc
  2023-11-10 18:00   ` Patrick O'Neill
@ 2023-11-19  4:08     ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2023-11-19  4:08 UTC (permalink / raw)
  To: Patrick O'Neill, gcc-patches; +Cc: gnu-toolchain



On 11/10/23 11:00, Patrick O'Neill wrote:
> 
> On 11/9/23 17:34, Jeff Law wrote:
>>
>>
>> On 11/3/23 00:18, Patrick O'Neill wrote:
>>> On non-vector targets dejagnu attempts dg-do compile for pr95401.cc.
>>> This produces a command like this:
>>> g++ pr95401.cc pr95401a.cc -S -o pr95401.s
>>>
>>> which isn't valid (gcc does not accept multiple input files when using
>>> -S with -o).
>>>
>>> This patch adds require-effective-target vect_int to avoid the case
>>> where the testcase is invoked with dg-do compile.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>>     * g++.dg/vect/pr95401.cc: Add require-effective-target vect_int.
>> Sorry, I must be missing something here.  I fail to see how adding an 
>> effective target check would/should impact the problem you've 
>> described above with the dg-additional-sources interaction with -S.
> 
> It's not intuitive (& probably not the cleanest way of solving it).
> 
> pr95401.cc is an invalid testcase when run with dg-do compile (for the 
> reasons above).
> 
> pr95401.cc 
> <https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/g%2B%2B.dg/vect/pr95401.cc;h=6a56dab095722b01d912416352df17f0d91dfd27;hb=HEAD> does not define a dg-do, which means it uses the testcase uses dg-do-what-default <https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/g%2B%2B.dg/vect/vect.exp;h=fc77120a83173c65ad147e8bb7c29ac82f06bb6d;hb=HEAD#l30> to determine what to do.
> dg-do-what-default is set by target-supports.exp 
> <https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/lib/target-supports.exp;h=1a7bea96c1e4ccb8ef30ac7012c04e8d44c5ad01;hb=HEAD#l11532>.
> 
> The two options here are set dg-do-what-default run or compile.
> On non-vector targets the pr95401 is set to compile (which is invalid).
> 
> Ideally we would say if dg-do-what-default == compile don't run, but 
> AFAIK that isn't possible.
> I didn't want to duplicate the check_vect_support_and_set_flags logic to 
> return true/false since that'll probably get out of sync.
> 
> I used require-effective-target vect_int as a proxy for 
> check_vect_support_and_set_flags (also since the testcase only contains 
> integer arrays).
> 
> That way we do this now:
> dg-do-what-default run -> run
> dg-do-what-default compile -> skip test
> 
> If there's a cleaner/better approach I'm happy to revise.
Another approach would be to make this a run test -- without actually 
running the vector bits.  ie, set it up so that it can safely run on any 
target.

volatile bool x = false;

main()
{
   if (x)
     call the vector function that already exists
   exit (0);
}

Though that may run afoul of other issues.

So if you want to go forward with your patch, that's fine, just add a 
comment about how adding the effective-target test works around the problem.

Thanks for the detailed explanation,

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-19  4:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-03  6:18 [PATCH] g++: Add require-effective-target to multi-input file testcase pr95401.cc Patrick O'Neill
2023-11-10  1:34 ` Jeff Law
2023-11-10 18:00   ` Patrick O'Neill
2023-11-19  4:08     ` Jeff Law

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).