[gcc r15-2783] testsuite, rs6000: Make {vmx, vsx, p8vector}_hw check for altivec/vsx feature
https://gcc.gnu.org/g:22b4e4fae86c86e15dd3d44cd653c70d65e0a993 commit r15-2783-g22b4e4fae86c86e15dd3d44cd653c70d65e0a993 Author: Kewen Lin Date: Wed Aug 7 02:03:54 2024 -0500 testsuite, rs6000: Make {vmx,vsx,p8vector}_hw check for altivec/vsx feature Different from p9vector_hw, vmx_hw/vsx_hw/p8vector_hw checks can still succeed without Altivec/VSX feature support. We have many runnable test cases only checking for these *_hw without extra checking for if Altivec/VSX feature enabled or not. It means they can fail if being tested by explicitly disabling Altivec/VSX. So I think it's reasonable to check if Altivec/VSX feature is enabled too while checking testing environment is able to execute some instructions since these instructions reply on these features. So similar to what we test for p9vector_hw, this patch is to modify C functions used for vmx_hw, vsx_hw and p8vector_hw with according vector types and constraints. For p8vector_hw, excepting for VSX feature, it also requires ISA 2.7 support. A good thing is that now almost all of the test cases using p8vector_hw have specified -mdejagnu-cpu=power8 always or if !has_arch_pwr8. Considering checking _ARCH_PWR8 in p8vector_hw can stop test cases being tested even if test case itself has specified -mdejagnu-cpu=power8, this patch doesn't force p8vector_hw to check _ARCH_PWR8, instead it updates all existing test cases which adopt p8vector_hw but don't have -mdejagnu-cpu=power8. By the way, all test cases adopting p9vector_hw are all fine. gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_vsx_hw_available): Modify C source code used for testing with type vector long long and constraint wa which require VSX feature. (check_p8vector_hw_available): Likewise. (check_vmx_hw_available): Modify C source code used for testing with type vector int and constraint v which require Altivec feature. * gcc.target/powerpc/divkc3-1.c: Specify -mdejagnu-cpu=power8 for !has_arch_pwr8 to ensure power8 support. * gcc.target/powerpc/mulkc3-1.c: Likewise. * gcc.target/powerpc/pr96264.c: Likewise. Diff: --- gcc/testsuite/gcc.target/powerpc/divkc3-1.c | 1 + gcc/testsuite/gcc.target/powerpc/mulkc3-1.c | 1 + gcc/testsuite/gcc.target/powerpc/pr96264.c | 1 + gcc/testsuite/lib/target-supports.exp | 24 +--- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/gcc/testsuite/gcc.target/powerpc/divkc3-1.c b/gcc/testsuite/gcc.target/powerpc/divkc3-1.c index 89bf04f12a97..96fb5c212042 100644 --- a/gcc/testsuite/gcc.target/powerpc/divkc3-1.c +++ b/gcc/testsuite/gcc.target/powerpc/divkc3-1.c @@ -1,5 +1,6 @@ /* { dg-do run { target { powerpc64*-*-* && p8vector_hw } } } */ /* { dg-options "-mfloat128 -mvsx" } */ +/* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */ void abort (); diff --git a/gcc/testsuite/gcc.target/powerpc/mulkc3-1.c b/gcc/testsuite/gcc.target/powerpc/mulkc3-1.c index b975a91dbd7a..1b0a1e24814a 100644 --- a/gcc/testsuite/gcc.target/powerpc/mulkc3-1.c +++ b/gcc/testsuite/gcc.target/powerpc/mulkc3-1.c @@ -1,5 +1,6 @@ /* { dg-do run { target { powerpc64*-*-* && p8vector_hw } } } */ /* { dg-options "-mfloat128 -mvsx" } */ +/* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */ void abort (); diff --git a/gcc/testsuite/gcc.target/powerpc/pr96264.c b/gcc/testsuite/gcc.target/powerpc/pr96264.c index 9f7d885daf2a..906720fdcd11 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr96264.c +++ b/gcc/testsuite/gcc.target/powerpc/pr96264.c @@ -1,5 +1,6 @@ /* { dg-do run { target { powerpc64le-*-* } } } */ /* { dg-options "-Os -fno-forward-propagate -fschedule-insns -fno-tree-ter -Wno-psabi" } */ +/* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */ /* { dg-require-effective-target p8vector_hw } */ typedef unsigned char __attribute__ ((__vector_size__ (64))) v512u8; diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index f8e5f5f36d03..26820b146d48 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -2887,11 +2887,9 @@ proc check_p8vector_hw_available { } { check_runtime_nocache p8vector_hw_available { int main() { - #ifdef __MACH__ - asm volatile ("xxlorc vs0,vs0,vs0"); - #else - asm volatile ("xxlorc 0,0,0"); - #endif + vector long long v1 = {0x1, 0x2}; + vector long long v2; + asm ("xxlorc %0,%1,%1" : "=wa" (v2) : "wa" (v1)); return 0; } } $options @@ -3188,11 +3186,9 @@ proc check_vsx_hw_ava
[gcc r15-2784] testsuite, rs6000: Remove useless powerpc_{altivec, vsx}_ok
https://gcc.gnu.org/g:9b4b4dd108f262c95f5ee8aff911e4193a26e55a commit r15-2784-g9b4b4dd108f262c95f5ee8aff911e4193a26e55a Author: Kewen Lin Date: Wed Aug 7 02:03:54 2024 -0500 testsuite, rs6000: Remove useless powerpc_{altivec,vsx}_ok Checking the existing powerpc_{altivec,vsx}_ok test cases, I found there are some test cases which don't require the checks powerpc_{altivec,vsx} even, some of them already have other effective target check which can cover check powerpc_{altivec,vsx}, or some of them don't actually require VSX/AltiVec feature at all. So this patch is to remove such useless checks. PR testsuite/114842 gcc/testsuite/ChangeLog: * gcc.target/powerpc/amo2.c: Remove powerpc_vsx_ok effective target check as p9vector_hw already covers it. * gcc.target/powerpc/p9-sign_extend-runnable.c: Likewise. * gcc.target/powerpc/clone2.c: Remove powerpc_vsx_ok effective target check as ppc_cpu_supports_hw already covers it. * gcc.target/powerpc/pr47251.c: Remove powerpc_vsx_ok effective target check as it doesn't need VSX. * gcc.target/powerpc/pr60137.c: Likewise. * gcc.target/powerpc/pr80098-1.c: Likewise. * gcc.target/powerpc/pr80098-2.c: Likewise. * gcc.target/powerpc/pr80098-3.c: Likewise. * gcc.target/powerpc/sd-pwr6.c: Likewise. * gcc.target/powerpc/pr57744.c: Remove powerpc_vsx_ok effective target check and option -mvsx as it doesn't need VSX. * gcc.target/powerpc/pr69548.c: Remove powerpc_vsx_ok effective target check as it doesn't need VSX, remove lp64 and use int128 instead. * gcc.target/powerpc/vec-cmpne-long.c: Remove powerpc_vsx_ok effective target check as p8vector_hw already covers it. * gcc.target/powerpc/darwin-save-world-1.c: Remove powerpc_altivec_ok effective target check as vmx_hw already covers it. Diff: --- gcc/testsuite/gcc.target/powerpc/amo2.c| 1 - gcc/testsuite/gcc.target/powerpc/clone2.c | 1 - gcc/testsuite/gcc.target/powerpc/darwin-save-world-1.c | 2 +- gcc/testsuite/gcc.target/powerpc/p9-sign_extend-runnable.c | 1 - gcc/testsuite/gcc.target/powerpc/pr47251.c | 1 - gcc/testsuite/gcc.target/powerpc/pr57744.c | 3 +-- gcc/testsuite/gcc.target/powerpc/pr60137.c | 1 - gcc/testsuite/gcc.target/powerpc/pr69548.c | 6 +++--- gcc/testsuite/gcc.target/powerpc/pr80098-1.c | 1 - gcc/testsuite/gcc.target/powerpc/pr80098-2.c | 1 - gcc/testsuite/gcc.target/powerpc/pr80098-3.c | 1 - gcc/testsuite/gcc.target/powerpc/sd-pwr6.c | 1 - gcc/testsuite/gcc.target/powerpc/vec-cmpne-long.c | 1 - 13 files changed, 5 insertions(+), 16 deletions(-) diff --git a/gcc/testsuite/gcc.target/powerpc/amo2.c b/gcc/testsuite/gcc.target/powerpc/amo2.c index 9cb493da53e9..592f0fb3f92d 100644 --- a/gcc/testsuite/gcc.target/powerpc/amo2.c +++ b/gcc/testsuite/gcc.target/powerpc/amo2.c @@ -1,5 +1,4 @@ /* { dg-do run { target { powerpc*-*-linux* && { lp64 && p9vector_hw } } } } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ /* { dg-options "-O2 -mvsx -mpower9-misc" } */ /* { dg-additional-options "-mdejagnu-cpu=power9" { target { ! has_arch_pwr9 } } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/clone2.c b/gcc/testsuite/gcc.target/powerpc/clone2.c index e64940b79527..4098e878c213 100644 --- a/gcc/testsuite/gcc.target/powerpc/clone2.c +++ b/gcc/testsuite/gcc.target/powerpc/clone2.c @@ -1,6 +1,5 @@ /* { dg-do run { target { powerpc*-*-linux* } } } */ /* { dg-options "-mvsx -O2" } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ /* { dg-require-effective-target ppc_cpu_supports_hw } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/darwin-save-world-1.c b/gcc/testsuite/gcc.target/powerpc/darwin-save-world-1.c index 3326765f4fb7..27fc1d30a8bb 100644 --- a/gcc/testsuite/gcc.target/powerpc/darwin-save-world-1.c +++ b/gcc/testsuite/gcc.target/powerpc/darwin-save-world-1.c @@ -1,7 +1,7 @@ /* { dg-do run { target powerpc*-*-* } } */ /* { dg-options "-maltivec" } */ /* { dg-require-effective-target powerpc_altivec } */ -/* { dg-skip-if "need to be able to execute AltiVec" { ! { powerpc_altivec_ok && vmx_hw } } } */ +/* { dg-skip-if "need to be able to execute AltiVec" { ! vmx_hw } } */ /* With altivec turned on, Darwin wants to save the world but we did not mark lr as being saved any more as saving the lr is not needed for saving altivec registers. */ diff --git a/gcc/testsuite/gcc.target/powerpc/p9-sign_extend-runnable.c b/gcc/testsuite/gcc.target/powerpc/p9-sign_extend-runnable.c index f0514993bc0d..595aa4768ccb 100644 --- a/gcc/testsuite/gcc.target/powerpc/p9-sign_extend-runnable.
[gcc r15-2788] testsuite, rs6000: Adjust pr78056-[1357].c and remove pr78056-[246].c
https://gcc.gnu.org/g:9db55ec0547e171eed8e7a7c50c8dad79d62fd65 commit r15-2788-g9db55ec0547e171eed8e7a7c50c8dad79d62fd65 Author: Kewen Lin Date: Wed Aug 7 02:03:55 2024 -0500 testsuite, rs6000: Adjust pr78056-[1357].c and remove pr78056-[246].c When cleaning up the remaining powerpc_{vsx,altivec}_ok test cases, I found some issues are related to pr78056-*.c. Firstly, the test points of pr78056-[246].c are no longer available since r9-3164 drops many HAVE_AS_* and the expected warning are dropped together, so this patch is to remove them. Secondly, pr78056-1.c and pr78056-3.c include altivec.h but don't use any builtins, checking powerpc_altivec is enough (don't need to check powerpc_vsx). And pr78056-5.c doesn't require any altivec/vsx feature, so powerpc_vsx_ok can be removed. Lastly, pr78056-7.c should just use powerpc_fprs instead of dfp_hw as it only cares about insn fcpsgn. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr78056-1.c: Check for powerpc_altivec rather than powerpc_vsx. * gcc.target/powerpc/pr78056-3.c: Likewise. * gcc.target/powerpc/pr78056-5.c: Drop powerpc_vsx_ok check. * gcc.target/powerpc/pr78056-7.c: Check for powerpc_fprs rather than dfp_hw. * gcc.target/powerpc/pr78056-2.c: Remove. * gcc.target/powerpc/pr78056-4.c: Remove. * gcc.target/powerpc/pr78056-6.c: Remove. Diff: --- gcc/testsuite/gcc.target/powerpc/pr78056-1.c | 4 ++-- gcc/testsuite/gcc.target/powerpc/pr78056-2.c | 18 -- gcc/testsuite/gcc.target/powerpc/pr78056-3.c | 4 ++-- gcc/testsuite/gcc.target/powerpc/pr78056-4.c | 19 --- gcc/testsuite/gcc.target/powerpc/pr78056-5.c | 2 -- gcc/testsuite/gcc.target/powerpc/pr78056-6.c | 25 - gcc/testsuite/gcc.target/powerpc/pr78056-7.c | 2 -- 7 files changed, 4 insertions(+), 70 deletions(-) diff --git a/gcc/testsuite/gcc.target/powerpc/pr78056-1.c b/gcc/testsuite/gcc.target/powerpc/pr78056-1.c index 72640007dbb6..49ebafe39b65 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr78056-1.c +++ b/gcc/testsuite/gcc.target/powerpc/pr78056-1.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-aix* } } */ -/* { dg-options "-mdejagnu-cpu=power8 -mvsx" } */ -/* { dg-require-effective-target powerpc_vsx } */ +/* { dg-options "-mdejagnu-cpu=power8" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* This test should succeed on both 32- and 64-bit configurations. */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/pr78056-2.c b/gcc/testsuite/gcc.target/powerpc/pr78056-2.c deleted file mode 100644 index 5cda9d6193b2.. --- a/gcc/testsuite/gcc.target/powerpc/pr78056-2.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do compile { target { powerpc*-*-* } } } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ -/* { dg-skip-if "" { powerpc_vsx_ok } } */ -/* { dg-skip-if "" { powerpc*-*-aix* } } */ -/* { dg-options "-mdejagnu-cpu=power8 -mvsx" } */ - -/* This test should succeed on both 32- and 64-bit configurations. */ -#include - -/* Though the command line specifies power8 target, this function is - to support power9. Expect an error message here because this target - does not support power9. */ -__attribute__((target("cpu=power9"))) -int get_random () -{ /* { dg-warning "lacks power9 support" } */ - return __builtin_darn_32 (); /* { dg-warning "implicit declaration" } */ -} - diff --git a/gcc/testsuite/gcc.target/powerpc/pr78056-3.c b/gcc/testsuite/gcc.target/powerpc/pr78056-3.c index cf57d058e8be..745552b244d0 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr78056-3.c +++ b/gcc/testsuite/gcc.target/powerpc/pr78056-3.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ -/* { dg-options "-mdejagnu-cpu=power7" } */ -/* { dg-require-effective-target powerpc_vsx } */ /* { dg-skip-if "" { powerpc*-*-aix* } } */ +/* { dg-options "-mdejagnu-cpu=power7" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* This test should succeed on both 32- and 64-bit configurations. */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/pr78056-4.c b/gcc/testsuite/gcc.target/powerpc/pr78056-4.c deleted file mode 100644 index 0bea0f895fac.. --- a/gcc/testsuite/gcc.target/powerpc/pr78056-4.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { dg-do compile { target { powerpc*-*-* } } } */ -/* powerpc_vsx_ok represents power7 */ -/* { dg-require-effective-target powerpc_vsx_ok } */ -/* { dg-skip-if "" { powerpc_vsx_ok } } */ -/* { dg-skip-if "" { powerpc*-*-aix* } } */ -/* { dg-options "-mdejagnu-cpu=power7" } */ - -/* This test should succeed on both 32- and 64-bit configurations. */ -#include - -/* Though the command line specifies power7 target, this function is - to support power8, which will fail because this platform does not - support power8
[gcc r15-2785] testsuite, rs6000: Replace powerpc_vsx_ok with powerpc_altivec etc.
https://gcc.gnu.org/g:4ddd886fececd83456d2d03dd6c191903dbca321 commit r15-2785-g4ddd886fececd83456d2d03dd6c191903dbca321 Author: Kewen Lin Date: Wed Aug 7 02:03:54 2024 -0500 testsuite, rs6000: Replace powerpc_vsx_ok with powerpc_altivec etc. This is a follow up patch for the previous patch adjusting powerpc_vsx_ok with powerpc_vsx, focusing on those test cases which don't really require VSX feature but used powerpc_vsx_ok before, they actually require some other effective target check, like some of them just require ALTIVEC feature, some of them just require hard float support, and some of them just require ISA 2.06 etc.. By the way, ppc-fpconv-4.c is the only one missing powerpc_fprs among ppc-fpconv-*.c after this replacement, so I also fix it here. PR testsuite/114842 gcc/testsuite/ChangeLog: * gcc.target/powerpc/bswap64-2.c: Replace powerpc_vsx_ok check with has_arch_pwr7. * gcc.target/powerpc/ppc-fpconv-2.c: Replace powerpc_vsx_ok check with powerpc_fprs. * gcc.target/powerpc/ppc-fpconv-6.c: Likewise. * gcc.target/powerpc/ppc-pow.c: Likewise. * gcc.target/powerpc/ppc-target-1.c: Likewise. * gcc.target/powerpc/ppc-target-2.c: Likewise. * gcc.target/powerpc/ppc-target-3.c: Likewise. * gcc.target/powerpc/ppc-target-4.c: Likewise. * gcc.target/powerpc/ppc-fpconv-4.c: Check for powerpc_fprs. * gcc.target/powerpc/fold-vec-select-char.c: Replace powerpc_vsx_ok with powerpc_altivec check and move it after dg-options line. * gcc.target/powerpc/fold-vec-select-float.c: Likewise. * gcc.target/powerpc/fold-vec-select-int.c: Likewise. * gcc.target/powerpc/fold-vec-select-short.c: Likewise. * gcc.target/powerpc/p9-novsx.c: Likewise. * gcc.target/powerpc/p9-options-1.c: Likewise. Diff: --- gcc/testsuite/gcc.target/powerpc/bswap64-2.c | 2 +- gcc/testsuite/gcc.target/powerpc/fold-vec-select-char.c | 2 +- gcc/testsuite/gcc.target/powerpc/fold-vec-select-float.c | 6 +++--- gcc/testsuite/gcc.target/powerpc/fold-vec-select-int.c | 2 +- gcc/testsuite/gcc.target/powerpc/fold-vec-select-short.c | 2 +- gcc/testsuite/gcc.target/powerpc/p9-novsx.c | 2 +- gcc/testsuite/gcc.target/powerpc/p9-options-1.c | 2 +- gcc/testsuite/gcc.target/powerpc/ppc-fpconv-2.c | 2 +- gcc/testsuite/gcc.target/powerpc/ppc-fpconv-4.c | 1 + gcc/testsuite/gcc.target/powerpc/ppc-fpconv-6.c | 2 +- gcc/testsuite/gcc.target/powerpc/ppc-pow.c | 2 +- gcc/testsuite/gcc.target/powerpc/ppc-target-1.c | 3 ++- gcc/testsuite/gcc.target/powerpc/ppc-target-2.c | 3 ++- gcc/testsuite/gcc.target/powerpc/ppc-target-3.c | 2 +- gcc/testsuite/gcc.target/powerpc/ppc-target-4.c | 2 +- 15 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gcc/testsuite/gcc.target/powerpc/bswap64-2.c b/gcc/testsuite/gcc.target/powerpc/bswap64-2.c index 6c3d8ca05289..70d872b5e304 100644 --- a/gcc/testsuite/gcc.target/powerpc/bswap64-2.c +++ b/gcc/testsuite/gcc.target/powerpc/bswap64-2.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-options "-O2 -mpopcntd" } */ /* { dg-require-effective-target lp64 } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-require-effective-target has_arch_pwr7 } */ /* { dg-final { scan-assembler "ldbrx" } } */ /* { dg-final { scan-assembler "stdbrx" } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-select-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-select-char.c index e055c017536b..17e28914aae4 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-select-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-select-char.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-select-float.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-select-float.c index 1656fbff2ca5..848bd750ff85 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-select-float.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-select-float.c @@ -1,9 +1,9 @@ -/* Verify that overloaded built-ins for vec_sel with float - inputs for VSX produce the right code. */ +/* Verify that overloaded built-ins for vec_sel with float + inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-select-int.c b/gcc/testsuite/gcc.target/powe
[gcc r15-2786] testsuite, rs6000: Replace powerpc_vsx_ok with powerpc_vsx
https://gcc.gnu.org/g:cdca23875296edd78327d3da6890bb334c28f2fd commit r15-2786-gcdca23875296edd78327d3da6890bb334c28f2fd Author: Kewen Lin Date: Wed Aug 7 02:03:55 2024 -0500 testsuite, rs6000: Replace powerpc_vsx_ok with powerpc_vsx Following up the previous r15-886, this patch to clean up the remaining powerpc_vsx_ok which actually should use powerpc_vsx instead. PR testsuite/114842 gcc/testsuite/ChangeLog: * gcc.target/powerpc/error-1.c: Replace powerpc_vsx_ok check with powerpc_vsx. * gcc.target/powerpc/warn-2.c: Likewise. * gcc.target/powerpc/fold-vec-logical-ors-longlong.c: Likewise. * gcc.target/powerpc/ppc-fortran/pr80108-1.f90: Replace powerpc_vsx_ok check with powerpc_vsx and remove useless -mfloat128. * gcc.target/powerpc/pragma_power8.c: Replace powerpc_vsx_ok check with powerpc_vsx. Diff: --- gcc/testsuite/gcc.target/powerpc/error-1.c | 2 +- gcc/testsuite/gcc.target/powerpc/fold-vec-logical-ors-longlong.c | 4 ++-- gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr80108-1.f90 | 4 ++-- gcc/testsuite/gcc.target/powerpc/pragma_power8.c | 5 - gcc/testsuite/gcc.target/powerpc/warn-2.c| 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/gcc.target/powerpc/error-1.c b/gcc/testsuite/gcc.target/powerpc/error-1.c index d38eba8bb8ad..9327076baf00 100644 --- a/gcc/testsuite/gcc.target/powerpc/error-1.c +++ b/gcc/testsuite/gcc.target/powerpc/error-1.c @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-require-effective-target powerpc_vsx } */ /* { dg-options "-O -mvsx -mno-altivec" } */ /* { dg-error "'-mvsx' and '-mno-altivec' are incompatible" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-logical-ors-longlong.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-logical-ors-longlong.c index 60af61a7f163..aae4694f5519 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-logical-ors-longlong.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-logical-ors-longlong.c @@ -4,7 +4,7 @@ /* { dg-do compile } */ /* { dg-options "-mvsx -O2" } */ /* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-require-effective-target powerpc_vsx } */ #include @@ -154,7 +154,7 @@ test6_nor (vector unsigned long long x, vector unsigned long long y) // The number of xxlor instructions generated varies between 6 and 24 for // older systems (power6,power7), as well as for 32-bit versus 64-bit targets. -// For simplicity, this test now only targets "powerpc_vsx_ok" environments +// For simplicity, this test now only targets "powerpc_vsx" environments // where the answer is expected to be 6. /* { dg-final { scan-assembler-times {\mxxlor\M} 6 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr80108-1.f90 b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr80108-1.f90 index 00392b5fed99..e0e157bd245a 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr80108-1.f90 +++ b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr80108-1.f90 @@ -1,7 +1,7 @@ ! Originally contributed by Tobias Burnas. ! { dg-do compile { target { powerpc*-*-* } } } -! { dg-require-effective-target powerpc_vsx_ok } -! { dg-options "-mdejagnu-cpu=405 -mpower9-minmax -mfloat128" } +! { dg-require-effective-target powerpc_vsx } +! { dg-options "-mdejagnu-cpu=405 -mpower9-minmax" } ! { dg-excess-errors "expect error due to conflicting target options" } ! Since the error message is not associated with a particular line ! number, we cannot use the dg-error directive and cannot specify a diff --git a/gcc/testsuite/gcc.target/powerpc/pragma_power8.c b/gcc/testsuite/gcc.target/powerpc/pragma_power8.c index 8de815e5a9e5..43ea6dd406e5 100644 --- a/gcc/testsuite/gcc.target/powerpc/pragma_power8.c +++ b/gcc/testsuite/gcc.target/powerpc/pragma_power8.c @@ -1,6 +1,9 @@ /* { dg-do compile } */ /* { dg-require-effective-target lp64 } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ +/* Ensure there is no explicit -mno-vsx etc., otherwise + the below bif __builtin_vec_vcmpeq_p replies on power8 + vsx would fail. */ +/* { dg-require-effective-target powerpc_vsx } */ /* { dg-options "-mdejagnu-cpu=power6 -maltivec -O2" } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/warn-2.c b/gcc/testsuite/gcc.target/powerpc/warn-2.c index 29c6ce50cd71..ba294cb52e55 100644 --- a/gcc/testsuite/gcc.target/powerpc/warn-2.c +++ b/gcc/testsuite/gcc.target/powerpc/warn-2.c @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target
[gcc r15-2787] testsuite, rs6000: Fix some run cases with appropriate _hw
https://gcc.gnu.org/g:3ab04f1f1dbfbf3ff0f8a934e27ac2adbd16d93a commit r15-2787-g3ab04f1f1dbfbf3ff0f8a934e27ac2adbd16d93a Author: Kewen Lin Date: Wed Aug 7 02:03:55 2024 -0500 testsuite, rs6000: Fix some run cases with appropriate _hw When cleaning up the remaining powerpc_{vsx,altivec}_ok test cases, I found some dg-do run test cases which should check for the appropriate {p8vector,vmx}_hw check instead. This patch is to adjust them accordingly. gcc/testsuite/ChangeLog: * gcc.target/powerpc/swaps-p8-46.c: Check for p8vector_hw rather than powerpc_vsx_ok. * gcc.target/powerpc/ppc64-abi-2.c: Check for vmx_hw rather than powerpc_altivec_ok. * gcc.target/powerpc/pr96139-c.c: Likewise. Diff: --- gcc/testsuite/gcc.target/powerpc/ppc64-abi-2.c | 2 +- gcc/testsuite/gcc.target/powerpc/pr96139-c.c | 2 +- gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.target/powerpc/ppc64-abi-2.c b/gcc/testsuite/gcc.target/powerpc/ppc64-abi-2.c index b490fc3c2fd8..2a5a76020049 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc64-abi-2.c +++ b/gcc/testsuite/gcc.target/powerpc/ppc64-abi-2.c @@ -1,4 +1,4 @@ -/* { dg-do run { target { { powerpc*-*-linux* && lp64 } && powerpc_altivec_ok } } } */ +/* { dg-do run { target { { powerpc*-*-linux* && lp64 } && vmx_hw } } } */ /* { dg-options "-O2 -fprofile -mprofile-kernel -maltivec -mabi=altivec -mno-pcrel" } */ #include #include diff --git a/gcc/testsuite/gcc.target/powerpc/pr96139-c.c b/gcc/testsuite/gcc.target/powerpc/pr96139-c.c index 3ada26034280..b39c559ec0ba 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr96139-c.c +++ b/gcc/testsuite/gcc.target/powerpc/pr96139-c.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-options "-O2 -Wall -maltivec" } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-require-effective-target vmx_hw } */ /* * Based on test created by sjmunroe for pr96139 diff --git a/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c b/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c index 3b5154b12312..d0392f25eeec 100644 --- a/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c +++ b/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c @@ -1,5 +1,5 @@ /* { dg-do run { target le } } */ -/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-require-effective-target p8vector_hw } */ /* { dg-options "-mdejagnu-cpu=power8 -mvsx -O2 " } */ typedef __attribute__ ((__aligned__ (8))) unsigned long long __m64;
[gcc r15-2789] tree-optimization/116166 - forward jump-threading going wild
https://gcc.gnu.org/g:2cf89ae83225f932b226cd57ef2d083a59bcf8a3 commit r15-2789-g2cf89ae83225f932b226cd57ef2d083a59bcf8a3 Author: Richard Biener Date: Tue Aug 6 14:56:26 2024 +0200 tree-optimization/116166 - forward jump-threading going wild Currently the forward threader isn't limited as to the search space it explores and with it now using path-ranger for simplifying conditions it runs into it became pretty slow for degenerate cases like compiling insn-emit.cc for RISC-V esp. when compiling for a host with LOGICAL_OP_NON_SHORT_CIRCUIT disabled. The following makes the forward threader honor the search space limit I introduced for the backward threader. This reduces compile-time from minutes to seconds for the testcase in PR116166. Note this wasn't necessary before we had ranger but with ranger the work we do is quadatic in the length of the threading path we build up (the same is true for the backwards threader). PR tree-optimization/116166 * tree-ssa-threadedge.h (jump_threader::thread_around_empty_blocks): Add limit parameter. (jump_threader::thread_through_normal_block): Likewise. * tree-ssa-threadedge.cc (jump_threader::thread_around_empty_blocks): Honor and decrement limit parameter. (jump_threader::thread_through_normal_block): Likewise. (jump_threader::thread_across_edge): Initialize limit from param_max_jump_thread_paths and pass it down to workers. Diff: --- gcc/tree-ssa-threadedge.cc | 30 ++ gcc/tree-ssa-threadedge.h | 4 ++-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/gcc/tree-ssa-threadedge.cc b/gcc/tree-ssa-threadedge.cc index 7f82639b8ecc..0aa2aa851430 100644 --- a/gcc/tree-ssa-threadedge.cc +++ b/gcc/tree-ssa-threadedge.cc @@ -786,13 +786,17 @@ propagate_threaded_block_debug_into (basic_block dest, basic_block src) bool jump_threader::thread_around_empty_blocks (vec *path, edge taken_edge, - bitmap visited) + bitmap visited, unsigned &limit) { basic_block bb = taken_edge->dest; gimple_stmt_iterator gsi; gimple *stmt; tree cond; + if (limit == 0) +return false; + --limit; + /* The key property of these blocks is that they need not be duplicated when threading. Thus they cannot have visible side effects such as PHI nodes. */ @@ -830,7 +834,8 @@ jump_threader::thread_around_empty_blocks (vec *path, m_registry->push_edge (path, taken_edge, EDGE_NO_COPY_SRC_BLOCK); m_state->append_path (taken_edge->dest); bitmap_set_bit (visited, taken_edge->dest->index); - return thread_around_empty_blocks (path, taken_edge, visited); + return thread_around_empty_blocks (path, taken_edge, visited, +limit); } } @@ -872,7 +877,7 @@ jump_threader::thread_around_empty_blocks (vec *path, m_registry->push_edge (path, taken_edge, EDGE_NO_COPY_SRC_BLOCK); m_state->append_path (taken_edge->dest); - thread_around_empty_blocks (path, taken_edge, visited); + thread_around_empty_blocks (path, taken_edge, visited, limit); return true; } @@ -899,8 +904,13 @@ jump_threader::thread_around_empty_blocks (vec *path, int jump_threader::thread_through_normal_block (vec *path, - edge e, bitmap visited) + edge e, bitmap visited, + unsigned &limit) { + if (limit == 0) +return 0; + limit--; + m_state->register_equivs_edge (e); /* PHIs create temporary equivalences. @@ -989,7 +999,7 @@ jump_threader::thread_through_normal_block (vec *path, visited. This may be overly conservative. */ bitmap_set_bit (visited, dest->index); bitmap_set_bit (visited, e->dest->index); - thread_around_empty_blocks (path, taken_edge, visited); + thread_around_empty_blocks (path, taken_edge, visited, limit); return 1; } } @@ -1075,9 +1085,12 @@ jump_threader::thread_across_edge (edge e) bitmap_set_bit (visited, e->src->index); bitmap_set_bit (visited, e->dest->index); + /* Limit search space. */ + unsigned limit = param_max_jump_thread_paths; + int threaded = 0; if ((e->flags & EDGE_DFS_BACK) == 0) -threaded = thread_through_normal_block (path, e, visited); +threaded = thread_through_normal_block (path, e, visited, limit); if (threaded > 0) { @@ -1148,11 +1161,12 @@ jump_threader::thread_across_edge (edge e) m_registry->push_edge (path, e, EDGE_START_JUMP_THREAD); m_registry->push_edge (path, taken_edge, EDGE_COPY_SRC_JOINER
[gcc r15-2790] c++: Fix up handling of dependent (late) attributes on function/method types [PR116175]
https://gcc.gnu.org/g:9426ce98ccb35a43b4f3e8ea14dcbf2f5de5dc48 commit r15-2790-g9426ce98ccb35a43b4f3e8ea14dcbf2f5de5dc48 Author: Jakub Jelinek Date: Wed Aug 7 09:48:07 2024 +0200 c++: Fix up handling of dependent (late) attributes on function/method types [PR116175] When working on unsequenced/reproducible attributes, I've noticed that on templates for some attributes decl_attributes isn't called at all, so they are kept in TYPE_ATTRIBUTES without any verification/transformations and also without argument substitution. The following patch fixes that for FUNCTION/METHOD_TYPE attributes. The included testcase ICEs without the pt.cc changes. 2024-08-07 Jakub Jelinek PR c++/116175 * pt.cc (apply_late_template_attributes): For function/method types call cp_build_type_attribute_variant on the non-dependent attributes. (rebuild_function_or_method_type): Add ARGS argument. Use apply_late_template_attributes rather than cp_build_type_attribute_variant. (maybe_rebuild_function_decl_type): Add ARGS argument, pass it to rebuild_function_or_method_type. (tsubst_function_decl): Adjust caller. (tsubst_function_type): Adjust rebuild_function_or_method_type caller. * g++.dg/ext/attr-format4.C: New test. Diff: --- gcc/cp/pt.cc| 24 gcc/testsuite/g++.dg/ext/attr-format4.C | 12 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 2db59213c549..542962b6387f 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -12201,6 +12201,8 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags, to our attributes parameter. */ gcc_assert (*p == attributes); } + else if (FUNC_OR_METHOD_TYPE_P (*decl_p)) +p = NULL; else { p = &TYPE_ATTRIBUTES (*decl_p); @@ -12219,7 +12221,10 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags, tree nondep = t; /* Apply any non-dependent attributes. */ - *p = nondep; + if (p) +*p = nondep; + else if (nondep) +*decl_p = cp_build_type_attribute_variant (*decl_p, nondep); if (nondep == attributes) return true; @@ -14377,8 +14382,9 @@ lookup_explicit_specifier (tree v) identical to T. */ static tree -rebuild_function_or_method_type (tree t, tree return_type, tree arg_types, -tree raises, tsubst_flags_t complain) +rebuild_function_or_method_type (tree t, tree args, tree return_type, +tree arg_types, tree raises, +tsubst_flags_t complain) { gcc_assert (FUNC_OR_METHOD_TYPE_P (t)); @@ -14411,7 +14417,9 @@ rebuild_function_or_method_type (tree t, tree return_type, tree arg_types, new_type = build_method_type_directly (r, return_type, TREE_CHAIN (arg_types)); } - new_type = cp_build_type_attribute_variant (new_type, TYPE_ATTRIBUTES (t)); + if (!apply_late_template_attributes (&new_type, TYPE_ATTRIBUTES (t), 0, + args, complain, NULL_TREE)) +return error_mark_node; cp_ref_qualifier rqual = type_memfn_rqual (t); bool late_return_type_p = TYPE_HAS_LATE_RETURN_TYPE (t); @@ -14424,7 +14432,7 @@ rebuild_function_or_method_type (tree t, tree return_type, tree arg_types, resolution for Core issues 1001/1322. */ static void -maybe_rebuild_function_decl_type (tree decl) +maybe_rebuild_function_decl_type (tree decl, tree args) { bool function_type_needs_rebuilding = false; if (tree parm_list = FUNCTION_FIRST_USER_PARM (decl)) @@ -14476,7 +14484,7 @@ maybe_rebuild_function_decl_type (tree decl) *q = void_list_node; TREE_TYPE (decl) -= rebuild_function_or_method_type (fntype, += rebuild_function_or_method_type (fntype, args, TREE_TYPE (fntype), new_parm_type_list, TYPE_RAISES_EXCEPTIONS (fntype), tf_none); } @@ -14659,7 +14667,7 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain, DECL_ARGUMENTS (r) = parms; DECL_RESULT (r) = NULL_TREE; - maybe_rebuild_function_decl_type (r); + maybe_rebuild_function_decl_type (r, args); TREE_STATIC (r) = 0; TREE_PUBLIC (r) = TREE_PUBLIC (t); @@ -15927,7 +15935,7 @@ tsubst_function_type (tree t, } /* Construct a new type node and return it. */ - return rebuild_function_or_method_type (t, return_type, arg_types, + return rebuild_function_or_method_type (t, args, return_type, arg_types, /*raises=*/NULL_TREE, complain); } diff --git a/gcc/testsuite/g++.dg/ext/attr-format4.C b/gcc/testsuite/g++.dg/ext/attr-format4.C new file mode 100644 index 00
[gcc r15-2791] vect: Fix vect_reduction_def check for odd/even widen mult [PR116142]
https://gcc.gnu.org/g:2083389a18d36684a88d9e2653bacc87ad894b50 commit r15-2791-g2083389a18d36684a88d9e2653bacc87ad894b50 Author: Xi Ruoyao Date: Tue Aug 6 17:48:42 2024 +0800 vect: Fix vect_reduction_def check for odd/even widen mult [PR116142] The check was implemented incorrectly, so vec_widen_smult_{even,odd}_M was never used. This is not good for targets with native even/odd widening multiplication but not lo/hi multiplication. The fix is actually developed by Richard Biener. gcc/ChangeLog: PR tree-optimization/116142 * tree-vect-stmts.cc (supportable_widening_operation): Remove an redundant and incorrect vect_reduction_def check, and fix the operand of another vect_reduction_def check. gcc/testsuite/ChangeLog: PR tree-optimization/116142 * gcc.target/i386/pr116142.c: New test. Co-authored-by: Richard Biener Diff: --- gcc/testsuite/gcc.target/i386/pr116142.c | 18 ++ gcc/tree-vect-stmts.cc | 3 +-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/pr116142.c b/gcc/testsuite/gcc.target/i386/pr116142.c new file mode 100644 index ..d288a50b237e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr116142.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512f -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump "WIDEN_MULT_EVEN_EXPR" "optimized" } } */ +/* { dg-final { scan-tree-dump "WIDEN_MULT_ODD_EXPR" "optimized" } } */ + +typedef __INT32_TYPE__ i32; +typedef __INT64_TYPE__ i64; + +i32 x[16], y[16]; + +i64 +test (void) +{ + i64 ret = 0; + for (int i = 0; i < 16; i++) +ret ^= (i64) x[i] * y[i]; + return ret; +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 20cae83e8206..385e63163c24 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -14179,7 +14179,6 @@ supportable_widening_operation (vec_info *vinfo, are properly set up for the caller. If we fail, we'll continue with a VEC_WIDEN_MULT_LO/HI_EXPR check. */ if (vect_loop - && STMT_VINFO_RELEVANT (stmt_info) == vect_used_by_reduction && !nested_in_vect_loop_p (vect_loop, stmt_info) && supportable_widening_operation (vinfo, VEC_WIDEN_MULT_EVEN_EXPR, stmt_info, vectype_out, @@ -14192,7 +14191,7 @@ supportable_widening_operation (vec_info *vinfo, same operation. One such an example is s += a * b, where elements in a and b cannot be reordered. Here we check if the vector defined by STMT is only directly used in the reduction statement. */ - tree lhs = gimple_assign_lhs (stmt_info->stmt); + tree lhs = gimple_assign_lhs (vect_orig_stmt (stmt_info)->stmt); stmt_vec_info use_stmt_info = loop_info->lookup_single_use (lhs); if (use_stmt_info && STMT_VINFO_DEF_TYPE (use_stmt_info) == vect_reduction_def)
[gcc r15-2792] c++: Fix ICE on valid involving variadic constructor [PR111592]
https://gcc.gnu.org/g:a1999cbc816ecd382c7af4ca44153379de49dcaf commit r15-2792-ga1999cbc816ecd382c7af4ca44153379de49dcaf Author: Simon Martin Date: Wed Aug 7 12:45:12 2024 +0200 c++: Fix ICE on valid involving variadic constructor [PR111592] We currently ICE upon the following valid code, due to the fix made through commit 9efe5fbde1e8 === cut here === struct ignore { ignore(...) {} }; template void InternalCompilerError(Args... args) { ignore{ ignore(args) ... }; } int main() { InternalCompilerError(0, 0); } === cut here === Change 9efe5fbde1e8 avoids infinite recursion in build_over_call by returning error_mark_node if one invokes ignore::ignore(...) with an argument of type ignore, because otherwise we end up calling convert_arg_to_ellipsis for that argument, and recurse into build_over_call with the exact same parameters. This patch tightens the condition to only return error_mark_node if there's one and only one parameter to the call being processed - otherwise we won't infinitely recurse. Successfully tested on x86_64-pc-linux-gnu. PR c++/111592 gcc/cp/ChangeLog: * call.cc (build_over_call): Only error out if there's a single parameter of type A in a call to A::A(...). gcc/testsuite/ChangeLog: * g++.dg/cpp0x/variadic186.C: New test. Diff: --- gcc/cp/call.cc | 1 + gcc/testsuite/g++.dg/cpp0x/variadic186.C | 11 +++ 2 files changed, 12 insertions(+) diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index a75e2e5e3afd..67d38e2a78a7 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -10365,6 +10365,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) a = decay_conversion (a, complain); } else if (DECL_CONSTRUCTOR_P (fn) + && vec_safe_length (args) == 1 && same_type_ignoring_top_level_qualifiers_p (DECL_CONTEXT (fn), TREE_TYPE (a))) { diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic186.C b/gcc/testsuite/g++.dg/cpp0x/variadic186.C new file mode 100644 index ..4a25a1a96bf8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic186.C @@ -0,0 +1,11 @@ +// PR c++/111592 +// { dg-do compile { target c++11 } } + +struct ignore { ignore(...) {} }; + +template +void InternalCompilerError(Args... args) +{ ignore{ ignore(args) ... }; } + +int main() +{ InternalCompilerError(0, 0); }
[gcc r15-2793] testsuite: Fix recent regression of g++.dg/other/sse2-pr85572-1.C
https://gcc.gnu.org/g:990a65fb1aa5d1b05a7737df879afb6900e2ce96 commit r15-2793-g990a65fb1aa5d1b05a7737df879afb6900e2ce96 Author: Roger Sayle Date: Wed Aug 7 12:52:26 2024 +0100 testsuite: Fix recent regression of g++.dg/other/sse2-pr85572-1.C My sincere apologies for not noticing that g++.dg/other/sse2-pr85572-1.C was FAILing with my recent ashrv2di patch. I'm not sure how that happened. Many thanks to Andrew Pinski for alerting me, and confirming that the changes are harmless/beneficial. Sorry again for the inconvenience. 2024-08-07 Roger Sayle gcc/testsuite/ChangeLog * g++.dg/other/sse2-pr85572-1.C: Update expected output after my recent patch for ashrv2di3. Now with one less instruction. Diff: --- gcc/testsuite/g++.dg/other/sse2-pr85572-1.C | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/g++.dg/other/sse2-pr85572-1.C b/gcc/testsuite/g++.dg/other/sse2-pr85572-1.C index e4c442394243..46edc065c33c 100644 --- a/gcc/testsuite/g++.dg/other/sse2-pr85572-1.C +++ b/gcc/testsuite/g++.dg/other/sse2-pr85572-1.C @@ -1,9 +1,10 @@ // PR target/85572 // { dg-do compile { target i?86-*-* x86_64-*-* } } // { dg-options "-O2 -msse2 -mno-sse3" } -// { dg-final { scan-assembler-times {\mpxor\M} 2 } } -// { dg-final { scan-assembler-times {\mpsubq\M} 2 } } -// { dg-final { scan-assembler-times {\mpsrlq\M} 1 } } +// { dg-final { scan-assembler-times {\mpsrad\M} 1 } } +// { dg-final { scan-assembler-times {\mpshufd\M} 1 } } +// { dg-final { scan-assembler-times {\mpxor\M} 1 } } +// { dg-final { scan-assembler-times {\mpsubq\M} 1 } } typedef long long V __attribute__((vector_size (16)));
[gcc r15-2794] tree-optimization/116258 - do not lower PAREN_EXPR of vectors
https://gcc.gnu.org/g:5b97d1a2102dca57918947d7e40a6ca68871 commit r15-2794-g5b97d1a2102dca57918947d7e40a6ca68871 Author: Richard Biener Date: Wed Aug 7 13:54:53 2024 +0200 tree-optimization/116258 - do not lower PAREN_EXPR of vectors The following avoids lowering of PAREN_EXPR of vectors as unsupported to scalars. Instead PAREN_EXPR is like a plain move or a VIEW_CONVERT. PR tree-optimization/116258 * tree-vect-generic.cc (expand_vector_operations_1): Do not lower PAREN_EXPR. * gcc.target/i386/pr116258.c: New testcase. Diff: --- gcc/testsuite/gcc.target/i386/pr116258.c | 14 ++ gcc/tree-vect-generic.cc | 9 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/pr116258.c b/gcc/testsuite/gcc.target/i386/pr116258.c new file mode 100644 index ..bd7d3a97b2c8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr116258.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2" } */ + +#define vect16 __attribute__((vector_size(16))) +#define h(a) __builtin_assoc_barrier((a)) + + vect16 float f( vect16 float x, vect16 float vconstants0) +{ + vect16 float t = (x * (vconstants0[0])); + return (x + h(t)); +} + +/* { dg-final { scan-assembler-times "shufps" 1 } } */ +/* { dg-final { scan-assembler-not "unpck" } } */ diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc index 8336cbb8c739..4bcab71c1683 100644 --- a/gcc/tree-vect-generic.cc +++ b/gcc/tree-vect-generic.cc @@ -2206,10 +2206,15 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi, } } + /* Plain moves do not need lowering. */ + if (code == SSA_NAME + || code == VIEW_CONVERT_EXPR + || code == PAREN_EXPR) +return; + if (CONVERT_EXPR_CODE_P (code) || code == FLOAT_EXPR - || code == FIX_TRUNC_EXPR - || code == VIEW_CONVERT_EXPR) + || code == FIX_TRUNC_EXPR) return; /* The signedness is determined from input argument. */
[gcc r15-2795] rs6000, Add new overloaded vector shift builtin int128 variants
https://gcc.gnu.org/g:083918a343d6cb9fd28c8b47dd1138220d95c820 commit r15-2795-g083918a343d6cb9fd28c8b47dd1138220d95c820 Author: Carl Love Date: Wed Aug 7 10:55:03 2024 -0400 rs6000, Add new overloaded vector shift builtin int128 variants Add the signed __int128 and unsigned __int128 argument types for the overloaded built-ins vec_sld, vec_sldb, vec_sldw, vec_sll, vec_slo, vec_srdb, vec_srl, vec_sro. For each of the new argument types add a testcase and update the documentation for the built-in. gcc/ChangeLog: * config/rs6000/altivec.md (vsdb_): Change define_insn iterator to VEC_IC. * config/rs6000/rs6000-builtins.def (__builtin_altivec_vsldoi_v1ti, __builtin_vsx_xxsldwi_v1ti, __builtin_altivec_vsldb_v1ti, __builtin_altivec_vsrdb_v1ti): New builtin definitions. * config/rs6000/rs6000-overload.def (vec_sld, vec_sldb, vec_sldw, vec_sll, vec_slo, vec_srdb, vec_srl, vec_sro): New overloaded definitions. * doc/extend.texi (vec_sld, vec_sldb, vec_sldw, vec_sll, vec_slo, vec_srdb, vec_srl, vec_sro): Add documentation for new overloaded built-ins. gcc/testsuite/ChangeLog: * gcc.target/powerpc/vec-shift-double-runnable-int128.c: New test file. Diff: --- gcc/config/rs6000/altivec.md | 6 +- gcc/config/rs6000/rs6000-builtins.def | 12 + gcc/config/rs6000/rs6000-overload.def | 40 ++ gcc/doc/extend.texi| 43 +++ .../powerpc/vec-shift-double-runnable-int128.c | 419 + 5 files changed, 517 insertions(+), 3 deletions(-) diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index aa9d8fffc901..1f5489b974f6 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -877,9 +877,9 @@ (define_int_iterator VSHIFT_DBL_LR [UNSPEC_SLDB UNSPEC_SRDB]) (define_insn "vsdb_" - [(set (match_operand:VI2 0 "register_operand" "=v") - (unspec:VI2 [(match_operand:VI2 1 "register_operand" "v") - (match_operand:VI2 2 "register_operand" "v") + [(set (match_operand:VEC_IC 0 "register_operand" "=v") + (unspec:VEC_IC [(match_operand:VEC_IC 1 "register_operand" "v") + (match_operand:VEC_IC 2 "register_operand" "v") (match_operand:QI 3 "const_0_to_12_operand" "n")] VSHIFT_DBL_LR))] "TARGET_POWER10" diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index 0c3c884c1104..5b513a7ef2b8 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -963,6 +963,9 @@ const vss __builtin_altivec_vsldoi_8hi (vss, vss, const int<4>); VSLDOI_8HI altivec_vsldoi_v8hi {} + const vsq __builtin_altivec_vsldoi_v1ti (vsq, vsq, const int<4>); +VSLDOI_1TI altivec_vsldoi_v1ti {} + const vss __builtin_altivec_vslh (vss, vus); VSLH vashlv8hi3 {} @@ -1799,6 +1802,9 @@ const vsll __builtin_vsx_xxsldwi_2di (vsll, vsll, const int<2>); XXSLDWI_2DI vsx_xxsldwi_v2di {} + const vsq __builtin_vsx_xxsldwi_v1ti (vsq, vsq, const int<2>); +XXSLDWI_1TI vsx_xxsldwi_v1ti {} + const vf __builtin_vsx_xxsldwi_4sf (vf, vf, const int<2>); XXSLDWI_4SF vsx_xxsldwi_v4sf {} @@ -3267,6 +3273,9 @@ const vss __builtin_altivec_vsldb_v8hi (vss, vss, const int<3>); VSLDB_V8HI vsldb_v8hi {} + const vsq __builtin_altivec_vsldb_v1ti (vsq, vsq, const int<3>); +VSLDB_V1TI vsldb_v1ti {} + const vsq __builtin_altivec_vslq (vsq, vuq); VSLQ vashlv1ti3 {} @@ -3285,6 +3294,9 @@ const vss __builtin_altivec_vsrdb_v8hi (vss, vss, const int<3>); VSRDB_V8HI vsrdb_v8hi {} + const vsq __builtin_altivec_vsrdb_v1ti (vsq, vsq, const int<3>); +VSRDB_V1TI vsrdb_v1ti {} + const vsq __builtin_altivec_vsrq (vsq, vuq); VSRQ vlshrv1ti3 {} diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def index c4ecafc6f7ef..87495aded49e 100644 --- a/gcc/config/rs6000/rs6000-overload.def +++ b/gcc/config/rs6000/rs6000-overload.def @@ -3399,6 +3399,10 @@ VSLDOI_4SF vd __builtin_vec_sld (vd, vd, const int); VSLDOI_2DF + vsq __builtin_vec_sld (vsq, vsq, const int); +VSLDOI_1TI VSLDOI_VSQ + vuq __builtin_vec_sld (vuq, vuq, const int); +VSLDOI_1TI VSLDOI_VUQ [VEC_SLDB, vec_sldb, __builtin_vec_sldb] vsc __builtin_vec_sldb (vsc, vsc, const int); @@ -3417,6 +3421,10 @@ VSLDB_V2DI VSLDB_VSLL vull __builtin_vec_sldb (vull, vull, const int); VSLDB_V2DI VSLDB_VULL + vsq __builtin_vec_sldb (vsq, vsq, const int); +VSLDB_V1TI VSLDB_VSQ + vuq __builtin_vec_sldb (vuq, vuq, const int); +VSLDB_V1TI VSLDB_VUQ [VEC_SLDW, vec_sldw, __builtin_vec_sldw] vsc __builtin_vec_sldw (vsc, vsc, const int); @@ -3439,6 +3447,10 @@ XXSLDWI_4SF XXSLDWI_VF vd __builtin_vec_sldw (vd, v
[gcc r15-2796] libgomp.c-c++-common/target-link-2.c: Fix test on multi-device systems
https://gcc.gnu.org/g:aa689684d2bf58d1b7e7938a1392e7a260276d14 commit r15-2796-gaa689684d2bf58d1b7e7938a1392e7a260276d14 Author: Tobias Burnus Date: Wed Aug 7 17:59:21 2024 +0200 libgomp.c-c++-common/target-link-2.c: Fix test on multi-device systems libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/target-link-2.c: Reset variable value to handle multi-device tests. Diff: --- libgomp/testsuite/libgomp.c-c++-common/target-link-2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libgomp/testsuite/libgomp.c-c++-common/target-link-2.c b/libgomp/testsuite/libgomp.c-c++-common/target-link-2.c index 15da1656ebf9..b64fbde70e3d 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/target-link-2.c +++ b/libgomp/testsuite/libgomp.c-c++-common/target-link-2.c @@ -54,6 +54,9 @@ int main() for (int i = 0; i < 10; i++) if (res[i] != (4 + i)*10) __builtin_abort (); + + for (int i = 0; i < 15; i++) /* Reset. */ + arr[i] /= 10; } return 0; }
[gcc r15-2797] aarch64/testsuite: Add testcases for recently fixed PRs
https://gcc.gnu.org/g:2c6174402ea315ecf618cfcba741e8cb18bc5282 commit r15-2797-g2c6174402ea315ecf618cfcba741e8cb18bc5282 Author: Andrew Pinski Date: Wed Aug 7 09:36:38 2024 -0700 aarch64/testsuite: Add testcases for recently fixed PRs The commit for PR 116258, added a x86_64 specific testcase, I thought it would be a good idea to add an aarch64 testcase too. And since it also fixed VLA vectors too so add a SVE testcase. Pushed as obvious after a test for aarch64-linux-gnu. PR middle-end/116258 PR middle-end/116259 gcc/testsuite/ChangeLog: * gcc.target/aarch64/pr116258.c: New test. * gcc.target/aarch64/sve/pr116259-1.c: New test. Signed-off-by: Andrew Pinski Diff: --- gcc/testsuite/gcc.target/aarch64/pr116258.c | 17 + gcc/testsuite/gcc.target/aarch64/sve/pr116259-1.c | 12 2 files changed, 29 insertions(+) diff --git a/gcc/testsuite/gcc.target/aarch64/pr116258.c b/gcc/testsuite/gcc.target/aarch64/pr116258.c new file mode 100644 index ..e727ad4b72a5 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr116258.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#pragma GCC target "+nosve" + +#define vect16 __attribute__((vector_size(16))) +#define h(a) __builtin_assoc_barrier((a)) + + vect16 float f( vect16 float x, vect16 float vconstants0) +{ + vect16 float t = (x * (vconstants0[0])); + return (x + h(t)); +} + +/* { dg-final { scan-assembler-times "\\\[0\\\]" 1 } } */ +/* { dg-final { scan-assembler-not "dup\t" } } */ +/* { dg-final { scan-assembler-not "ins\t" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr116259-1.c b/gcc/testsuite/gcc.target/aarch64/sve/pr116259-1.c new file mode 100644 index ..bb2eed4728c0 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/pr116259-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* PR middle-end/116259 */ + +#include + +/* PAREN_EXPR lowering for VLA vectors was ICEing. + It should not be lowered in a similar way as moves + are not lowered. */ +svfloat64_t f(svfloat64_t x) +{ + return __builtin_assoc_barrier(x); +}
[gcc r15-2798] c++: Implement CWG2387 - Linkage of const-qualified variable template [PR109126]
https://gcc.gnu.org/g:82cd63a63eaa61a4ed5c4029a1869be7446ecb3c commit r15-2798-g82cd63a63eaa61a4ed5c4029a1869be7446ecb3c Author: Jakub Jelinek Date: Wed Aug 7 19:08:07 2024 +0200 c++: Implement CWG2387 - Linkage of const-qualified variable template [PR109126] The following patch attempts to implement DR2387 by making variable templates including their specialization TREE_PUBLIC when at file scope and they don't have static storage class. 2024-08-07 Jakub Jelinek PR c++/109126 * decl.cc (grokvardecl): Implement CWG 2387 - Linkage of const-qualified variable template. Set TREE_PUBLIC on variable templates with const qualified types unless static is present. * g++.dg/DRs/dr2387.C: New test. * g++.dg/DRs/dr2387-aux.cc: New file. Diff: --- gcc/cp/decl.cc | 2 ++ gcc/testsuite/g++.dg/DRs/dr2387-aux.cc | 25 + gcc/testsuite/g++.dg/DRs/dr2387.C | 22 ++ 3 files changed, 49 insertions(+) diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 86d2bfab22dc..a468bfdb7b67 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -11225,6 +11225,8 @@ grokvardecl (tree type, || ! constp || volatilep || inlinep + || in_template_context + || processing_specialization || module_attach_p ())); TREE_STATIC (decl) = ! DECL_EXTERNAL (decl); } diff --git a/gcc/testsuite/g++.dg/DRs/dr2387-aux.cc b/gcc/testsuite/g++.dg/DRs/dr2387-aux.cc new file mode 100644 index ..7a78ac230157 --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr2387-aux.cc @@ -0,0 +1,25 @@ +// DR 2387 + +template +extern const int a; +template +static const int b = N; +template +extern const int c; +template +extern const volatile int d; +template +extern const int e; +extern const int *pa, *pb, *pc, *pe; +extern const volatile int *pd; + +int +main () +{ + if (pa != &a <42> + || pb == &b <42> + || pc != &c <42> + || pd != &d <42> + || pe != &e <43>) +__builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/DRs/dr2387.C b/gcc/testsuite/g++.dg/DRs/dr2387.C new file mode 100644 index ..afbe618d5179 --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr2387.C @@ -0,0 +1,22 @@ +// DR 2387 +// { dg-do run { target c++14 } } +// { dg-additional-sources "dr2387-aux.cc" } + +template +const int a = N; +template +static const int b = N; +template +extern const int c = N; +template +const volatile int d = N; +template +const int e = N; +template <> +const int e <43> = 44; + +const int *pa = &a <42>; +const int *pb = &b <42>; +const int *pc = &c <42>; +const volatile int *pd = &d <42>; +const int *pe = &e <43>;
[gcc r15-2799] OpenMP: Constructors and destructors for "declare target" static aggregates
https://gcc.gnu.org/g:f1bfba3a9b3f31e3e06bfd1911c9f223869ea03f commit r15-2799-gf1bfba3a9b3f31e3e06bfd1911c9f223869ea03f Author: Tobias Burnus Date: Wed Aug 7 19:31:19 2024 +0200 OpenMP: Constructors and destructors for "declare target" static aggregates This commit also compile-time expands (__builtin_)omp_is_initial_device for both Fortran and C/C++ (unless, -fno-builtin-omp_is_initial_device is used). But the main change is: This commit adds support for running constructors and destructors for static (file-scope) aggregates for C++ objects which are marked with "declare target" directives on OpenMP offload targets. Before this commit, space is allocated on the target for such aggregates, but nothing ever constructs them properly, so they end up zero-initialised. (See the new test static-aggr-constructor-destructor-3.C for a reason why running constructors on the target is preferable to e.g. constructing on the host and then copying the resulting object to the target.) 2024-08-07 Julian Brown Tobias Burnus gcc/ChangeLog: * builtins.def (DEF_GOMP_BUILTIN_COMPILER): Define DEF_GOMP_BUILTIN_COMPILER to handle the non-prefix version. * gimple-fold.cc (gimple_fold_builtin_omp_is_initial_device): New. (gimple_fold_builtin): Call it. * omp-builtins.def (BUILT_IN_OMP_IS_INITIAL_DEVICE): Define. * tree.cc (get_file_function_name): Support names for on-target constructor/destructor functions. gcc/cp/ * decl2.cc (tree-inline.h): Include. (static_init_fini_fns): Bump to four entries. Update comment. (start_objects, start_partial_init_fini_fn): Add 'omp_target' parameter. Support "declare target" decls. Update forward declaration. (emit_partial_init_fini_fn): Add 'host_fn' parameter. Return tree for the created function. Support "declare target". (OMP_SSDF_IDENTIFIER): New macro. (partition_vars_for_init_fini): Support partitioning "declare target" variables also. (generate_ctor_or_dtor_function): Add 'omp_target' parameter. Support "declare target" decls. (c_parse_final_cleanups): Support constructors/destructors on OpenMP offload targets. gcc/fortran/ChangeLog: * gfortran.h (gfc_option_t): Add disable_omp_is_initial_device. * lang.opt (fbuiltin-): Add. * options.cc (gfc_handle_option): Handle -fno-builtin-omp_is_initial_device. * f95-lang.cc (gfc_init_builtin_functions): Handle DEF_GOMP_BUILTIN_COMPILER. * trans-decl.cc (gfc_get_extern_function_decl): Add code to use DEF_GOMP_BUILTIN_COMPILER for 'omp_is_initial_device'. libgomp/ChangeLog: * testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C: New test. * testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C: New test. * testsuite/libgomp.c++/static-aggr-constructor-destructor-3.C: New test. * testsuite/libgomp.c-c++-common/target-is-initial-host.c: New test. * testsuite/libgomp.c-c++-common/target-is-initial-host-2.c: New test. * testsuite/libgomp.fortran/target-is-initial-host.f: New test. * testsuite/libgomp.fortran/target-is-initial-host.f90: New test. * testsuite/libgomp.fortran/target-is-initial-host-2.f90: New test. Co-authored-by: Tobias Burnus Diff: --- gcc/builtins.def | 4 + gcc/cp/decl2.cc| 229 + gcc/fortran/f95-lang.cc| 9 + gcc/fortran/gfortran.h | 1 + gcc/fortran/lang.opt | 4 + gcc/fortran/options.cc | 12 ++ gcc/fortran/trans-decl.cc | 9 + gcc/gimple-fold.cc | 20 ++ gcc/omp-builtins.def | 4 + gcc/tree.cc| 6 +- .../static-aggr-constructor-destructor-1.C | 72 +++ .../static-aggr-constructor-destructor-2.C | 50 + .../static-aggr-constructor-destructor-3.C | 36 .../target-is-initial-host-2.c | 43 .../libgomp.c-c++-common/target-is-initial-host.c | 42 .../libgomp.fortran/target-is-initial-host-2.f90 | 37 .../libgomp.fortran/target-is-initial-host.f | 35 .../libgomp.fortran/target-is-initial-host.f90 | 35 18 files changed, 608 insertions(+), 40 deletions(-) diff --git a/gcc/builtins.def b/gcc/builtins.def index f6f3e104f6a8..a3921aa6856a 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.de
[gcc r15-2800] Don't call clean_symbol_name in create_tmp_var_name [PR116219]
https://gcc.gnu.org/g:165e3e7c3ba884345647c0f1c9a3a57a03383651 commit r15-2800-g165e3e7c3ba884345647c0f1c9a3a57a03383651 Author: Jakub Jelinek Date: Wed Aug 7 20:14:31 2024 +0200 Don't call clean_symbol_name in create_tmp_var_name [PR116219] SRA adds fancy names like offset$D94316$_M_impl$D93629$_M_start where the numbers in there are DECL_UIDs if there are unnamed FIELD_DECLs etc. Because -g0 vs. -g can cause differences between the exact DECL_UID values (add bigger gaps in between them, corresponding decls should still be ordered the same based on DECL_UID) we make sure such decls have DECL_NAMELESS set and depending on exact options either don't dump such names at all or dump_fancy_name sanitizes the D123456$ parts in there to D$. Unfortunately in tons of places we then use get_name to grab either user names or these SRA created names and use that as argument to create_tmp_var{,_name,_raw} to base other artificial temporary names based on that. Those are DECL_NAMELESS too, but unfortunately create_tmp_var_name starting with https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=725494f6e4121eace43b7db1202f8ecbf52a8276 calls clean_symbol_name which replaces the $s in there with _s and thus dump_fancy_name doesn't sanitize it anymore. I don't see any discussion of that commit (originally to TM branch, later merged) on the mailing list, but from DECL_NAME (new_decl) = create_tmp_var_name (IDENTIFIER_POINTER (DECL_NAME (old_decl))); - SET_DECL_ASSEMBLER_NAME (new_decl, NULL_TREE); + SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl)); snippet elsewhere in that commit it seems create_tmp_var_name was used at that point also to determine function names of clones, so presumably the clean_symbol_name at that point was to ensure the symbol could be emitted into assembly, maybe in case DECL_NAME is something like C++ operators or whatever could have there undesirable characters. Anyway, we don't do that for years anymore, already GCC 4.5 uses for such purposes clone_function_name which starts of DECL_ASSEMBLER_NAME of the old function and appends based on supportable symbol suffix separators the separator and some suffix and/or number, so that part doesn't go through create_tmp_var_name. I don't see problems with having the $ and . etc. characters in the names intended just to make dumps more readable, after all, we already are using those in the SRA created names. Those names shouldn't make it into the assembly in any way, neither debug info nor assembly labels. There is one theoretical case, where the gimplifier promotes automatic vars into TREE_STATIC ones and therefore those can then appear in assembly, just in case it would be on e.g. SRA created names and regimplified later. Because no cases of promotion of DECL_NAMELESS vars to static was observed in {x86_64,i686,powerpc64le}-linux bootstraps/regtests, the code simply uses C.NNN names for DECL_NAMELESS vars like it does for !DECL_NAME vars. Richi mentioned on IRC that the non-cleaned up names might make things harder to feed stuff back to the GIMPLE FE, but if so, I think it should be the dumping for GIMPLE FE purposes that cleans those up (but at that point it should also verify if some such cleaned up names don't collide with others and somehow deal with those). 2024-08-07 Jakub Jelinek PR c++/116219 * gimple-expr.cc (remove_suffix): Formatting fixes. (create_tmp_var_name): Don't call clean_symbol_name. * gimplify.cc (gimplify_init_constructor): When promoting automatic DECL_NAMELESS vars to static, don't preserve their DECL_NAME. Diff: --- gcc/gimple-expr.cc | 16 ++-- gcc/gimplify.cc| 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc index f8d7185530c6..0477c9d5f448 100644 --- a/gcc/gimple-expr.cc +++ b/gcc/gimple-expr.cc @@ -406,14 +406,12 @@ remove_suffix (char *name, int len) { int i; - for (i = 2; i < 7 && len > i; i++) -{ - if (name[len - i] == '.') - { - name[len - i] = '\0'; - break; - } -} + for (i = 2; i < 7 && len > i; i++) +if (name[len - i] == '.') + { + name[len - i] = '\0'; + break; + } } /* Create a new temporary name with PREFIX. Return an identifier. */ @@ -430,8 +428,6 @@ create_tmp_var_name (const char *prefix) char *preftmp = ASTRDUP (prefix); remove_suffix (preftmp, strlen (preftmp)); - clean_symbol_name (preftmp); - prefix = preftmp; } diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 30bfecf67e5e..71cc6c38d807 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -5599,7 +5599,7 @@ gimplify_init_constructor (tree *exp
[gcc r15-2801] Partially support streaming of poly_int for offloading.
https://gcc.gnu.org/g:38900247f3880d6eca2e364a000e5898f8deae64 commit r15-2801-g38900247f3880d6eca2e364a000e5898f8deae64 Author: Prathamesh Kulkarni Date: Wed Aug 7 23:45:38 2024 +0530 Partially support streaming of poly_int for offloading. When offloading is enabled, the patch streams out host NUM_POLY_INT_COEFFS, and changes streaming in as follows: if (host_num_poly_int_coeffs <= NUM_POLY_INT_COEFFS) { for (i = 0; i < host_num_poly_int_coeffs; i++) poly_int.coeffs[i] = stream_in coeff; for (; i < NUM_POLY_INT_COEFFS; i++) poly_int.coeffs[i] = 0; } else { for (i = 0; i < NUM_POLY_INT_COEFFS; i++) poly_int.coeffs[i] = stream_in coeff; /* Ensure that degree of poly_int <= accel NUM_POLY_INT_COEFFS. */ for (; i < host_num_poly_int_coeffs; i++) { val = stream_in coeff; if (val != 0) error (); } } gcc/ChangeLog: PR ipa/96265 PR ipa/111937 * data-streamer-in.cc (streamer_read_poly_uint64): Remove code for streaming, and call poly_int_read_common instead. (streamer_read_poly_int64): Likewise. * data-streamer.cc (host_num_poly_int_coeffs): Conditionally define new variable if ACCEL_COMPILER is defined. * data-streamer.h (host_num_poly_int_coeffs): Declare. (poly_int_read_common): New function template. (bp_unpack_poly_value): Remove code for streaming and call poly_int_read_common instead. * lto-streamer-in.cc (lto_input_mode_table): Stream-in host NUM_POLY_INT_COEFFS into host_num_poly_int_coeffs if ACCEL_COMPILER is defined. * lto-streamer-out.cc (lto_write_mode_table): Stream out NUM_POLY_INT_COEFFS if offloading is enabled. * poly-int.h (MAX_NUM_POLY_INT_COEFFS_BITS): New macro. * tree-streamer-in.cc (lto_input_ts_poly_tree_pointers): Adjust streaming-in of poly_int. Signed-off-by: Prathamesh Kulkarni Diff: --- gcc/data-streamer-in.cc | 12 gcc/data-streamer.cc| 8 gcc/data-streamer.h | 49 + gcc/lto-streamer-in.cc | 5 + gcc/lto-streamer-out.cc | 3 +++ gcc/poly-int.h | 4 gcc/tree-streamer-in.cc | 33 +++-- 7 files changed, 100 insertions(+), 14 deletions(-) diff --git a/gcc/data-streamer-in.cc b/gcc/data-streamer-in.cc index 7dce2928ef03..07dbc5e2bc36 100644 --- a/gcc/data-streamer-in.cc +++ b/gcc/data-streamer-in.cc @@ -182,10 +182,8 @@ streamer_read_hwi (class lto_input_block *ib) poly_uint64 streamer_read_poly_uint64 (class lto_input_block *ib) { - poly_uint64 res; - for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i) -res.coeffs[i] = streamer_read_uhwi (ib); - return res; + using coeff_type = poly_int_traits::coeff_type; + return poly_int_read_common (streamer_read_uhwi, ib); } /* Read a poly_int64 from IB. */ @@ -193,10 +191,8 @@ streamer_read_poly_uint64 (class lto_input_block *ib) poly_int64 streamer_read_poly_int64 (class lto_input_block *ib) { - poly_int64 res; - for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i) -res.coeffs[i] = streamer_read_hwi (ib); - return res; + using coeff_type = poly_int_traits::coeff_type; + return poly_int_read_common (streamer_read_hwi, ib); } /* Read gcov_type value from IB. */ diff --git a/gcc/data-streamer.cc b/gcc/data-streamer.cc index 346b294c72ac..896413e8d2b6 100644 --- a/gcc/data-streamer.cc +++ b/gcc/data-streamer.cc @@ -28,6 +28,14 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "data-streamer.h" +/* For offloading -- While streaming-out, host NUM_POLY_INT_COEFFS is + stored at beginning of mode_table. While streaming-in, the value is read + in host_num_poly_int_coeffs. */ + +#ifdef ACCEL_COMPILER +unsigned host_num_poly_int_coeffs = 0; +#endif + /* Pack WORK into BP in a variant of uleb format. */ void diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h index 6a2596134ceb..b3dc4b984767 100644 --- a/gcc/data-streamer.h +++ b/gcc/data-streamer.h @@ -50,6 +50,7 @@ void bp_pack_real_value (struct bitpack_d *, const REAL_VALUE_TYPE *); void bp_unpack_real_value (struct bitpack_d *, REAL_VALUE_TYPE *); unsigned HOST_WIDE_INT bp_unpack_var_len_unsigned (struct bitpack_d *); HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *); +extern unsigned host_num_poly_int_coeffs; /* In data-streamer-out.cc */ void streamer_write_zero (struct output_block *); @@ -194,15 +195,55 @@ bp_unpack_value (struct bitpack_d *bp, unsigned nbits) return val & mask; } +/* Common code for reading poly_int. */ + +template +poly_int +poly_int_read_common (F read_coeff, Args ...args) +{ + poly_int x; + unsigned i; + +#ifdef ACCEL_COMPILER + /* Ensur
[gcc r15-2802] c++: erroneous partial spec vs primary tmpl [PR116064]
https://gcc.gnu.org/g:d1fc9816df81e953308428641685d6ec6d84c9ac commit r15-2802-gd1fc9816df81e953308428641685d6ec6d84c9ac Author: Patrick Palka Date: Wed Aug 7 14:28:26 2024 -0400 c++: erroneous partial spec vs primary tmpl [PR116064] When a partial specialization is deemed erroneous at parse time, we currently flag the primary template as erroneous instead. Later at instantiation time we check if the primary template is erroneous rather than the selected partial specialization, so at least we're consistent. But it's better not to conflate a partial specialization with the primary template since they're instantiated independenty. This avoids rejecting the instantiation of A in the below testcase. PR c++/116064 gcc/cp/ChangeLog: * error.cc (get_current_template): If the current scope is a partial specialization, return it instead of the primary template. * pt.cc (instantiate_class_template): Pass the partial specialization if any to maybe_diagnose_erroneous_template instead of the primary template. gcc/testsuite/ChangeLog: * g++.dg/template/permissive-error2.C: New test. Reviewed-by: Jason Merrill Diff: --- gcc/cp/error.cc | 6 +- gcc/cp/pt.cc | 2 +- gcc/testsuite/g++.dg/template/permissive-error2.C | 15 +++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 6c22ff55b463..879e5a115cfe 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -173,7 +173,11 @@ get_current_template () { if (scope_chain && in_template_context && !current_instantiation ()) if (tree ti = get_template_info (current_scope ())) - return TI_TEMPLATE (ti); + { + if (PRIMARY_TEMPLATE_P (TI_TEMPLATE (ti)) && TI_PARTIAL_INFO (ti)) + ti = TI_PARTIAL_INFO (ti); + return TI_TEMPLATE (ti); + } return NULL_TREE; } diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 542962b6387f..3e55d5c0fea5 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -12381,7 +12381,7 @@ instantiate_class_template (tree type) if (! push_tinst_level (type)) return type; - maybe_diagnose_erroneous_template (templ); + maybe_diagnose_erroneous_template (t ? TI_TEMPLATE (t) : templ); int saved_unevaluated_operand = cp_unevaluated_operand; int saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings; diff --git a/gcc/testsuite/g++.dg/template/permissive-error2.C b/gcc/testsuite/g++.dg/template/permissive-error2.C new file mode 100644 index ..692e7c7ac82c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/permissive-error2.C @@ -0,0 +1,15 @@ +// PR c++/116064 +// { dg-additional-options -fpermissive } +// Verify we correctly mark a partial specialization as erroneous +// instead its primary template. + +template +struct A { }; + +template +struct A { // { dg-error "instantiating erroneous template" } + void f(typename A::type); // { dg-warning "does not name a type" } +}; + +A a; // { dg-bogus "" } +A b; // { dg-message "required from here" }
[gcc r15-2803] Darwin: Recognise -weak_framework in the driver [PR116237].
https://gcc.gnu.org/g:4cec7bc79db52bae159c3c60a415e2aea48051d8 commit r15-2803-g4cec7bc79db52bae159c3c60a415e2aea48051d8 Author: Iain Sandoe Date: Mon Aug 5 13:19:28 2024 +0100 Darwin: Recognise -weak_framework in the driver [PR116237]. XCode compilers recognise the weak_framework linker option in the driver and forward it. This patch makes GCC adopt the same behaviour. PR target/116237 gcc/ChangeLog: * config/darwin.h (SUBTARGET_DRIVER_SELF_SPECS): Add a spec for weak_framework. * config/darwin.opt: Handle weak_framework driver option. Signed-off-by: Iain Sandoe Diff: --- gcc/config/darwin.h | 2 ++ gcc/config/darwin.opt | 4 2 files changed, 6 insertions(+) diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index c09b9e9dc94d..377599074a75 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -264,6 +264,8 @@ extern GTY(()) int darwin_ms_struct; "%{weak_reference_mismatches*:\ -Xlinker -weak_reference_mismatches -Xlinker %*} \ %Do not export the global symbols listed in . +weak_framework +Driver RejectNegative Separate +-weak_framework Make a weak link to the specified framework. + weak_reference_mismatches Driver RejectNegative Separate -weak_reference_mismatches Specifies what to do if a symbol import conflicts between file (weak in one and not in another) the default is to treat the symbol as non-weak.
[gcc/devel/fortran_unsigned] Add some rudimentary documentation.
https://gcc.gnu.org/g:95f108c0d6ee83f20481d780d622168bd20e8585 commit 95f108c0d6ee83f20481d780d622168bd20e8585 Author: Thomas Koenig Date: Tue Aug 6 20:00:05 2024 +0200 Add some rudimentary documentation. Diff: --- gcc/fortran/gfortran.texi | 67 +++ gcc/fortran/invoke.texi | 5 +++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 7e8783a36903..f0cdbaef557c 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -1192,6 +1192,7 @@ extensions. @menu * Extensions implemented in GNU Fortran:: * Extensions not implemented in GNU Fortran:: +* Experimental features for Fortran 202Y:: @end menu @@ -2701,7 +2702,73 @@ descriptor occurred, use @code{INQUIRE} to get the file position, count the characters up to the next @code{NEW_LINE} and then start reading from the position marked previously. +@node Experimental features for Fortran 202Y +@section Experimental features for Fortran 202Y +@cindex Fortran 202Y +GNU Fortran supports some experimental features which have been +proposed and accepted by the J3 standards committee. These +exist to give users a chance to try them out, and to provide +a reference implementation. + +As these features have not been finalized, there is a chance that the +version in the upcoming standard will differ from what GNU Fortran +currently implements. Stability of these implementations is therefore +not guaranteed. + +@menu +* Unsigned integers:: +@end menu + +@node Unsigned integers +@subsection Unsigned integers +@cindex Unsigned integers +GNU Fortran supports unsigned integers according to +@uref{https://j3-fortran.org/doc/year/24/24-116.txt, J3/24-116}. The +data type is called @code{UNSIGNED}. For an unsigned type with $n$ bits, +it implements integer arithmetic modulo @code{2**n}, comparable to the +@code{unsigned} data type in C. + +The data type has @code{KIND} numbers comparable to other Fortran data +types, which can be selected via the @code{SELECTED_UNSIGNED_KIND} +function. + +Mixed arithmetic, comparisoins and assignment between @code{UNSIGNED} +and other types are only possible via explicit conversion. Conversion +from @code{UNSIGNED} to other types is done via type conversion +functions like @code{INT} or @code{REAL}. Unsigned variables cannot be +used as index variables in @code{DO} loops or as array indices. + +Unsigned numbers have a trailing @code{u} as suffix, optionally followed +by a @code{KIND} number separated by an underscore. + +Input and output can be done using the @code{I} and (to be +implemented) @code{X}, @code{O} and @code{Z} descriptors, plus +unformatted I/O. + +Here is a small, somewhat contrived example of their use: +@smallexample +program main + unsigned(kind=8) :: v + v = huge(v) - 32u_8 + print *,v +end program main +@end smallexample +which will output the number 18446744073709551583. + +Generally, unsigned integers are only permitted as data in intrinsics, +not, for example, for counting bits. +As of now, the following intrinsics take unsigned arguments: +@itemize @bullet +@item @code{BLT}, @code{BLE}, @code{BGE} and @code{BGT}. These intrinsics + are actually redundante because comparison operators could be used + directly. +@item @code{IAND}, @code{IOR}, @code{IEOR} and @code{NOT} +@item @code{BIT_SIZE}, @code{DIGITS} and @code{HUGE} +@item @code{DSHIFTL} and @code{DSHIFTR} +@item @code{IBCLR}, @code{IBITS} and @code{IBITS} +@end itemize +This list will grow in the near future. @c - @c - @c Mixed-Language Programming diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 6bc42afe2c4f..dcb5782ef4b2 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -129,7 +129,7 @@ by type. Explanations are in the following sections. -fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp -fopenmp-allocators -fopenmp-simd -freal-4-real-10 -freal-4-real-16 -freal-4-real-8 -freal-8-real-10 -freal-8-real-16 -freal-8-real-4 --std=@var{std} -ftest-forall-temp +-std=@var{std} -ftest-forall-temp -funsigned } @item Preprocessing Options @@ -611,6 +611,9 @@ earlier gfortran versions and should not be used any more. @item -ftest-forall-temp Enhance test coverage by forcing most forall assignments to use temporary. +@opindex @code{funsigned} +@item -funsigned +Allow the experimental unsigned extension. @end table @node Preprocessing Options
[gcc/devel/fortran_unsigned] Add test case for B, Z and O descriptors.
https://gcc.gnu.org/g:58cbd148ed210f33102dd04cfcb8cfb6d7d1dd76 commit 58cbd148ed210f33102dd04cfcb8cfb6d7d1dd76 Author: Thomas Koenig Date: Tue Aug 6 20:14:36 2024 +0200 Add test case for B, Z and O descriptors. Diff: --- gcc/fortran/gfortran.texi | 5 ++- gcc/testsuite/gfortran.dg/unsigned_10.f90 | 56 +++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index f0cdbaef557c..1afd12fcf14c 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -2742,9 +2742,8 @@ used as index variables in @code{DO} loops or as array indices. Unsigned numbers have a trailing @code{u} as suffix, optionally followed by a @code{KIND} number separated by an underscore. -Input and output can be done using the @code{I} and (to be -implemented) @code{X}, @code{O} and @code{Z} descriptors, plus -unformatted I/O. +Input and output can be done using the @code{I}, @code{B}, @code{O} +and @code{Z} descriptors, plus unformatted I/O. Here is a small, somewhat contrived example of their use: @smallexample diff --git a/gcc/testsuite/gfortran.dg/unsigned_10.f90 b/gcc/testsuite/gfortran.dg/unsigned_10.f90 new file mode 100644 index ..df9167649fe4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unsigned_10.f90 @@ -0,0 +1,56 @@ +! { dg-do run } +! { dg-options "-funsigned" } +! Test I/O with Z, O and B descriptors. + +program main + implicit none + unsigned(kind=8) :: u,v + integer :: i + open(10,status="scratch") + u = 3u + do i=0,63 + write (10,'(Z16)') u + u = u + u + end do + rewind 10 + u = 3u + do i=0,63 + read (10,'(Z16)') v + if (u /= v) then +print *,u,v + end if + u = u + u + end do + rewind 10 + u = 3u + do i=0,63 + write (10,'(O22)') u + u = u + u + end do + rewind 10 + u = 3u + do i=0,63 + read (10,'(O22)') v + if (u /= v) then +print *,u,v + end if + u = u + u + end do + + rewind 10 + u = 3u + do i=0,63 + write (10,'(B64)') u + u = u + u + end do + rewind 10 + u = 3u + do i=0,63 + read (10,'(B64)') v + if (u /= v) then +print *,u,v + end if + u = u + u + end do + +end program main
[gcc/devel/fortran_unsigned] Min, MAX and ishft(c).
https://gcc.gnu.org/g:d5c05281bacf79bca1c10c34135aa61e14be8acb commit d5c05281bacf79bca1c10c34135aa61e14be8acb Author: Thomas Koenig Date: Wed Aug 7 21:44:48 2024 +0200 Min, MAX and ishft(c). Diff: --- gcc/fortran/check.cc | 53 +-- gcc/fortran/gfortran.texi | 2 ++ gcc/fortran/simplify.cc | 20 +--- gcc/testsuite/gfortran.dg/unsigned_11.f90 | 23 ++ gcc/testsuite/gfortran.dg/unsigned_12.f90 | 18 +++ gcc/testsuite/gfortran.dg/unsigned_13.f90 | 18 +++ 6 files changed, 120 insertions(+), 14 deletions(-) diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 54a84ae40756..108e05dbe74e 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -3472,8 +3472,18 @@ gfc_check_intconv (gfc_expr *x) bool gfc_check_ishft (gfc_expr *i, gfc_expr *shift) { - if (!type_check (i, 0, BT_INTEGER) - || !type_check (shift, 1, BT_INTEGER)) + if (flag_unsigned) +{ + if (!type_check2 (i, 0, BT_INTEGER, BT_UNSIGNED)) + return false; +} + else +{ + if (!type_check (i, 0, BT_INTEGER)) + return false; +} + + if (!type_check (shift, 1, BT_INTEGER)) return false; if (!less_than_bitsize1 ("I", i, NULL, shift, true)) @@ -3486,9 +3496,16 @@ gfc_check_ishft (gfc_expr *i, gfc_expr *shift) bool gfc_check_ishftc (gfc_expr *i, gfc_expr *shift, gfc_expr *size) { - if (!type_check (i, 0, BT_INTEGER) - || !type_check (shift, 1, BT_INTEGER)) -return false; + if (flag_unsigned) +{ + if (!type_check2 (i, 0, BT_INTEGER, BT_UNSIGNED)) + return false; +} + else +{ + if (!type_check (i, 0, BT_INTEGER)) + return false; +} if (size != NULL) { @@ -3962,11 +3979,29 @@ gfc_check_min_max (gfc_actual_arglist *arg) gfc_current_intrinsic, &x->where)) return false; } - else if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL) + else { - gfc_error ("% argument of %qs intrinsic at %L must be INTEGER, " -"REAL or CHARACTER", gfc_current_intrinsic, &x->where); - return false; + if (flag_unsigned) + { + if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL + && x->ts.type != BT_UNSIGNED) + { + gfc_error ("% argument of %qs intrinsic at %L must be " +"INTEGER, REAL, CHARACTER or UNSIGNED", +gfc_current_intrinsic, &x->where); + return false; + } + } + else + { + if (x->ts.type != BT_INTEGER && x->ts.type != BT_REAL) + { + gfc_error ("% argument of %qs intrinsic at %L must be " +"INTEGER, REAL or CHARACTER", +gfc_current_intrinsic, &x->where); + return false; + } + } } return check_rest (x->ts.type, x->ts.kind, arg); diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 1afd12fcf14c..aeb4fe9ee0bc 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -2766,6 +2766,8 @@ As of now, the following intrinsics take unsigned arguments: @item @code{BIT_SIZE}, @code{DIGITS} and @code{HUGE} @item @code{DSHIFTL} and @code{DSHIFTR} @item @code{IBCLR}, @code{IBITS} and @code{IBITS} +@item @code{MIN} and @code{MAX} +@item @code{ISHFT} and @code{ISHFTC} @end itemize This list will grow in the near future. @c - diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index b7b280754e90..05396035b58e 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -3931,8 +3931,11 @@ simplify_shift (gfc_expr *e, gfc_expr *s, const char *name, gfc_extract_int (s, &shift); - k = gfc_validate_kind (BT_INTEGER, e->ts.kind, false); - bitsize = gfc_integer_kinds[k].bit_size; + k = gfc_validate_kind (e->ts.type, e->ts.kind, false); + if (e->ts.type == BT_INTEGER) +bitsize = gfc_integer_kinds[k].bit_size; + else +bitsize = gfc_unsigned_kinds[k].bit_size; result = gfc_get_constant_expr (e->ts.type, e->ts.kind, &e->where); @@ -4008,7 +4011,11 @@ simplify_shift (gfc_expr *e, gfc_expr *s, const char *name, } } - gfc_convert_mpz_to_signed (result->value.integer, bitsize); + if (result->ts.type == BT_INTEGER) +gfc_convert_mpz_to_signed (result->value.integer, bitsize); + else +gfc_reduce_unsigned(result); + free (bits); return result; @@ -4108,7 +4115,8 @@ gfc_simplify_ishftc (gfc_expr *e, gfc_expr *s, gfc_expr *sz) if (shift == 0) return result; - gfc_convert_mpz_to_unsigned (result->value.integer, isize); + if (result->ts.type == BT_INTEGER) +gfc_convert_mpz_to_unsigned (result->value.integer, isize); bits = XCNEWVEC (int, ssize); @@ -4154,7 +4162,8 @@ gfc_simplify_ishftc (gfc_expr *e, gfc_expr *s, gf
[gcc r15-2804] compiler: don't assume that ATTRIBUTE_UNUSED is defined
https://gcc.gnu.org/g:ac8a87c4e345c71c32984625ce4a5a74a710b501 commit r15-2804-gac8a87c4e345c71c32984625ce4a5a74a710b501 Author: Ian Lance Taylor Date: Wed Aug 7 13:24:22 2024 -0700 compiler: don't assume that ATTRIBUTE_UNUSED is defined Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/604075 Diff: --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/lex.h | 8 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index e13dc5f58a3d..3a839410e9cc 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -5f6fae5ff33e996243acd098c71904695c414c53 +6aa463fef2d8f04e0bd2675f63a6529df080a44a The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/lex.h b/gcc/go/gofrontend/lex.h index 701e5d4b353b..452ef95f334f 100644 --- a/gcc/go/gofrontend/lex.h +++ b/gcc/go/gofrontend/lex.h @@ -12,6 +12,12 @@ #include "operator.h" #include "go-linemap.h" +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# define GO_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#else +# define GO_ATTRIBUTE_UNUSED +#endif + struct Unicode_range; // The keywords. These must be in sorted order, other than @@ -561,7 +567,7 @@ class Lex gather_embed(const char*, const char*); // The input file name. - const char* input_file_name_ ATTRIBUTE_UNUSED; + const char* input_file_name_ GO_ATTRIBUTE_UNUSED; // The input file. FILE* input_file_; // The object used to keep track of file names and line numbers.
[gcc r15-2806] c++/modules: Clarify error message in read_enum_def
https://gcc.gnu.org/g:c0ad382caa38873bb6078edf5314930504bc01f1 commit r15-2806-gc0ad382caa38873bb6078edf5314930504bc01f1 Author: Nathaniel Shead Date: Wed Aug 7 19:17:52 2024 +1000 c++/modules: Clarify error message in read_enum_def This error message reads to me the wrong way around, particularly in the context of other errors. Updated so that the ellipsis connect. gcc/cp/ChangeLog: * module.cc (trees_in::read_enum_def): Clarify error. gcc/testsuite/ChangeLog: * g++.dg/modules/enum-bad-1_b.C: Update error message. Signed-off-by: Nathaniel Shead Diff: --- gcc/cp/module.cc| 4 ++-- gcc/testsuite/g++.dg/modules/enum-bad-1_b.C | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 723f0890d96e..0f3e1d97c53b 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -12687,9 +12687,9 @@ trees_in::read_enum_def (tree defn, tree maybe_template) if (known_decl && new_decl) { inform (DECL_SOURCE_LOCATION (new_decl), - "... this enumerator %qD", new_decl); + "enumerator %qD does not match ...", new_decl); inform (DECL_SOURCE_LOCATION (known_decl), - "enumerator %qD does not match ...", known_decl); + "... this enumerator %qD", known_decl); } else if (known_decl || new_decl) { diff --git a/gcc/testsuite/g++.dg/modules/enum-bad-1_b.C b/gcc/testsuite/g++.dg/modules/enum-bad-1_b.C index b01cd66a14d0..23e17b088a2c 100644 --- a/gcc/testsuite/g++.dg/modules/enum-bad-1_b.C +++ b/gcc/testsuite/g++.dg/modules/enum-bad-1_b.C @@ -13,13 +13,13 @@ import "enum-bad-1_a.H"; ONE one; -// { dg-regexp {In module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:5:6: error: definition of 'enum ONE' does not match\n[^\n]*enum-bad-1_b.C:3:6: note: existing definition 'enum ONE'\nIn module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:5:11: note: ... this enumerator 'A'\n[^\n]*enum-bad-1_b.C:3:11: note: enumerator 'Q' does not match ...\n[^\n]*enum-bad-1_b.C:15:1: note: during load of binding '::ONE'\n} } +// { dg-regexp {In module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:5:6: error: definition of 'enum ONE' does not match\n[^\n]*enum-bad-1_b.C:3:6: note: existing definition 'enum ONE'\nIn module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:5:11: note: enumerator 'A' does not match ...\n[^\n]*enum-bad-1_b.C:3:11: note: ... this enumerator 'Q'\n[^\n]*enum-bad-1_b.C:15:1: note: during load of binding '::ONE'\n} } int i = TWO; -// { dg-regexp {In module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:6:6: error: definition of 'enum' does not match\n[^\n]*enum-bad-1_b.C:4:6: note: existing definition 'enum'\nIn module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:6:12: note: ... this enumerator 'THREE'\n[^\n]*enum-bad-1_b.C:4:12: note: enumerator 'DREI' does not match ...\n[^\n]*enum-bad-1_b.C:18:9: note: during load of binding '::TWO'\n} } +// { dg-regexp {In module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:6:6: error: definition of 'enum' does not match\n[^\n]*enum-bad-1_b.C:4:6: note: existing definition 'enum'\nIn module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:6:12: note: enumerator 'THREE' does not match ...\n[^\n]*enum-bad-1_b.C:4:12: note: ... this enumerator 'DREI'\n[^\n]*enum-bad-1_b.C:18:9: note: during load of binding '::TWO'\n} } FOUR four; -// { dg-regexp {In module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:7:6: error: definition of 'enum FOUR' does not match\n[^\n]*enum-bad-1_b.C:5:6: note: existing definition 'enum FOUR'\nIn module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:7:12: note: ... this enumerator 'B'\n[^\n]*enum-bad-1_b.C:5:12: note: enumerator 'B' does not match ...\n[^\n]*enum-bad-1_b.C:21:1: note: during load of binding '::FOUR'\n} } +// { dg-regexp {In module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:7:6: error: definition of 'enum FOUR' does not match\n[^\n]*enum-bad-1_b.C:5:6: note: existing definition 'enum FOUR'\nIn module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:7:12: note: enumerator 'B' does not match ...\n[^\n]*enum-bad-1_b.C:5:12: note: ... this enumerator 'B'\n[^\n]*enum-bad-1_b.C:21:1: note: during load of binding '::FOUR'\n} } FIVE five; // { dg-regexp {In module [^\n]*enum-bad-1_a.H, imported at [^\n]*enum-bad-1_b.C:8:\n[^\n]*enum-bad-1_a.H:8:6: error: definition of 'enum FIVE' does not matc
[gcc r15-2807] c++/modules: Fix merging of GM entities in partitions [PR114950]
https://gcc.gnu.org/g:c592310d5275e09977504c136419686bd2277af0 commit r15-2807-gc592310d5275e09977504c136419686bd2277af0 Author: Nathaniel Shead Date: Mon Aug 5 22:37:57 2024 +1000 c++/modules: Fix merging of GM entities in partitions [PR114950] Currently name lookup generally seems to assume that all entities declared within a named module (partition) are attached to said module, which is not true for GM entities (e.g. via extern "C++"), and causes issues with deduplication. This patch fixes the issue by ensuring that module attachment of a declaration is consistently used to handling merging. Handling this exposes some issues with deduplicating temploid friends; to resolve this we always create the BINDING_SLOT_PARTITION slot so that we have somewhere to place attached names (from any module). This doesn't yet completely handle issues with allowing otherwise conflicting temploid friends from different modules to co-exist in the same module if neither are reachable from the other via name lookup. PR c++/114950 gcc/cp/ChangeLog: * module.cc (trees_out::decl_value): Stream bit indicating imported temploid friends early. (trees_in::decl_value): Use this bit with key_mergeable. (trees_in::key_mergeable): Allow merging attached declarations if they're imported temploid friends (which must be namespace scope). (module_state::read_cluster): Check for GM entities that may require merging even when importing from partitions. * name-lookup.cc (enum binding_slots): Adjust comment. (get_fixed_binding_slot): Always create partition slot. (name_lookup::search_namespace_only): Support binding vectors with both partition and GM entities to dedup. (walk_module_binding): Likewise. (name_lookup::adl_namespace_fns): Likewise. (set_module_binding): Likewise. (check_module_override): Use attachment of the decl when checking overrides rather than named_module_p. (lookup_imported_hidden_friend): Use partition slot for finding mergeable template bindings. * name-lookup.h (set_module_binding): Split mod_glob_flag parameter into separate global_p and partition_p params. gcc/testsuite/ChangeLog: * g++.dg/modules/tpl-friend-13_e.C: Adjust error message. * g++.dg/modules/ambig-2_a.C: New test. * g++.dg/modules/ambig-2_b.C: New test. * g++.dg/modules/part-9_a.C: New test. * g++.dg/modules/part-9_b.C: New test. * g++.dg/modules/part-9_c.C: New test. * g++.dg/modules/tpl-friend-15.h: New test. * g++.dg/modules/tpl-friend-15_a.C: New test. * g++.dg/modules/tpl-friend-15_b.C: New test. * g++.dg/modules/tpl-friend-15_c.C: New test. Signed-off-by: Nathaniel Shead Reviewed-by: Jason Merrill Diff: --- gcc/cp/module.cc | 52 + gcc/cp/name-lookup.cc | 65 +- gcc/cp/name-lookup.h | 2 +- gcc/testsuite/g++.dg/modules/ambig-2_a.C | 7 +++ gcc/testsuite/g++.dg/modules/ambig-2_b.C | 10 gcc/testsuite/g++.dg/modules/part-9_a.C| 10 gcc/testsuite/g++.dg/modules/part-9_b.C| 10 gcc/testsuite/g++.dg/modules/part-9_c.C| 8 gcc/testsuite/g++.dg/modules/tpl-friend-13_e.C | 4 +- gcc/testsuite/g++.dg/modules/tpl-friend-15.h | 11 + gcc/testsuite/g++.dg/modules/tpl-friend-15_a.C | 8 gcc/testsuite/g++.dg/modules/tpl-friend-15_b.C | 8 gcc/testsuite/g++.dg/modules/tpl-friend-15_c.C | 7 +++ 13 files changed, 148 insertions(+), 54 deletions(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 0f3e1d97c53b..58ad8cbdb614 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -2958,7 +2958,8 @@ private: public: tree decl_container (); tree key_mergeable (int tag, merge_kind, tree decl, tree inner, tree type, - tree container, bool is_attached); + tree container, bool is_attached, + bool is_imported_temploid_friend); unsigned binfo_mergeable (tree *); private: @@ -7806,6 +7807,7 @@ trees_out::decl_value (tree decl, depset *dep) || !TYPE_PTRMEMFUNC_P (TREE_TYPE (decl))); merge_kind mk = get_merge_kind (decl, dep); + bool is_imported_temploid_friend = imported_temploid_friends->get (decl); if (CHECKING_P) { @@ -7841,13 +7843,11 @@ trees_out::decl_value (tree decl, depset *dep) && DECL_MODULE_ATTACH_P (not_tmpl)) is_attached = true; - /* But don't consider imported temploid friends as attached, -
[gcc r15-2808] c++/modules: Handle instantiating already tsubsted template friend classes [PR115801]
https://gcc.gnu.org/g:79209273663672ff05663554741fd2558b4aac99 commit r15-2808-g79209273663672ff05663554741fd2558b4aac99 Author: Nathaniel Shead Date: Tue Aug 6 15:41:38 2024 +1000 c++/modules: Handle instantiating already tsubsted template friend classes [PR115801] With modules it may be the case that a template friend class provided with a qualified name is not found by name lookup at instantiation time, due to the class not being exported from its module. This causes issues in tsubst_friend_class which did not handle this case. This is caused by the named friend class not actually requiring tsubsting. This was already worked around for the "found by name lookup" case (g++.dg/template/friend5.C), but it looks like there's no need to do name lookup at all for this particular case to work. We do need to be careful to continue to do name lookup to handle templates from an outer current instantiation though; this patch adds a new testcase for this as well. This should not impact modules (because exportingness will only affect namespace lookup). PR c++/115801 gcc/cp/ChangeLog: * pt.cc (tsubst_friend_class): Return the type immediately when no tsubsting or name lookup is required. gcc/testsuite/ChangeLog: * g++.dg/modules/tpl-friend-16_a.C: New test. * g++.dg/modules/tpl-friend-16_b.C: New test. * g++.dg/template/friend82.C: New test. Signed-off-by: Nathaniel Shead Reviewed-by: Patrick Palka Reviewed-by: Jason Merrill Diff: --- gcc/cp/pt.cc | 8 ++ gcc/testsuite/g++.dg/modules/tpl-friend-16_a.C | 40 ++ gcc/testsuite/g++.dg/modules/tpl-friend-16_b.C | 17 +++ gcc/testsuite/g++.dg/template/friend82.C | 23 +++ 4 files changed, 88 insertions(+) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 3e55d5c0fea5..1dde7d167fd6 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -11732,6 +11732,14 @@ tsubst_friend_class (tree friend_tmpl, tree args) return TREE_TYPE (tmpl); } + if (TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (friend_tmpl)) == 1) +/* The template has already been fully substituted, e.g. for + +template friend class ::C; + + so we can just return it directly. */ +return TREE_TYPE (friend_tmpl); + tree context = CP_DECL_CONTEXT (friend_tmpl); if (TREE_CODE (context) == NAMESPACE_DECL) push_nested_namespace (context); diff --git a/gcc/testsuite/g++.dg/modules/tpl-friend-16_a.C b/gcc/testsuite/g++.dg/modules/tpl-friend-16_a.C new file mode 100644 index ..e1cdcd98e1e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/tpl-friend-16_a.C @@ -0,0 +1,40 @@ +// PR c++/115801 +// { dg-additional-options "-fmodules-ts -Wno-global-module" } +// { dg-module-cmi test } + +module; + +template struct GMF; +template struct GMF_Hidden { + int go() { GMF gmf; return gmf.x; } +}; + +template struct GMF { +private: + template friend struct ::GMF_Hidden; + int x = 1; +}; + +template int test_gmf() { + GMF_Hidden h; return h.go(); +} + +export module test; + +export using ::GMF; +export using ::test_gmf; + +export template struct Attached; +template struct Attached_Hidden { + int go() { Attached attached; return attached.x; } +}; + +template struct Attached { +private: + template friend struct ::Attached_Hidden; + int x = 2; +}; + +export template int test_attached() { + Attached_Hidden h; return h.go(); +} diff --git a/gcc/testsuite/g++.dg/modules/tpl-friend-16_b.C b/gcc/testsuite/g++.dg/modules/tpl-friend-16_b.C new file mode 100644 index ..d3484ab19b11 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/tpl-friend-16_b.C @@ -0,0 +1,17 @@ +// PR c++/115801 +// { dg-additional-options "-fmodules-ts" } + +import test; + +int main() { + GMF gmf; + Attached attached; + + int a = test_gmf(); + int b = test_attached(); + + GMF_Hidden gmf_hidden; // { dg-error "not declared" } + Attached_Hidden attached_hidden; // { dg-error "not declared" } +} + +// { dg-prune-output "expected primary-expression" } diff --git a/gcc/testsuite/g++.dg/template/friend82.C b/gcc/testsuite/g++.dg/template/friend82.C new file mode 100644 index ..28a057dd23e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend82.C @@ -0,0 +1,23 @@ +// { dg-do compile } + +template +struct A { + template struct B; + + template + struct C { +template friend struct A::B; + private: +int x; + }; +}; + +template +template +struct A::B { + int foo(A::C c) { return c.x; } // { dg-error "private" } +}; + +template struct A::C; +template struct A::B; // { dg-bogus "" } +template struct A::B; // { dg-message "required from here" }
[gcc r15-2809] RISC-V: Minimal support for Zimop extension.
https://gcc.gnu.org/g:c8f3fdd53871a20838be532b58ef610bf1dd75e1 commit r15-2809-gc8f3fdd53871a20838be532b58ef610bf1dd75e1 Author: Jiawei Date: Fri Aug 2 23:23:14 2024 +0800 RISC-V: Minimal support for Zimop extension. This patch support Zimop and Zcmop extension[1].To enable GCC to recognize and process Zimop and Zcmop extension correctly at compile time. https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc gcc/ChangeLog: * common/config/riscv/riscv-common.cc: New extension. * config/riscv/riscv.opt: New mask. gcc/testsuite/ChangeLog: * gcc.target/riscv/arch-42.c: New test. * gcc.target/riscv/arch-43.c: New test. Diff: --- gcc/common/config/riscv/riscv-common.cc | 8 gcc/config/riscv/riscv.opt | 7 +++ gcc/testsuite/gcc.target/riscv/arch-42.c | 5 + gcc/testsuite/gcc.target/riscv/arch-43.c | 5 + 4 files changed, 25 insertions(+) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 1944c7785c48..62c6e1dab1fd 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -97,6 +97,8 @@ static const riscv_implied_info_t riscv_implied_info[] = {"zabha", "zaamo"}, {"zacas", "zaamo"}, + {"zcmop", "zca"}, + {"b", "zba"}, {"b", "zbb"}, {"b", "zbs"}, @@ -319,6 +321,9 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"zicclsm", ISA_SPEC_CLASS_NONE, 1, 0}, {"ziccrse", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zimop", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zcmop", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zicntr", ISA_SPEC_CLASS_NONE, 2, 0}, {"zihpm", ISA_SPEC_CLASS_NONE, 2, 0}, @@ -1629,6 +1634,9 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = {"zicbop", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOP}, {"zic64b", &gcc_options::x_riscv_zicmo_subext, MASK_ZIC64B}, + {"zimop",&gcc_options::x_riscv_mop_subext, MASK_ZIMOP}, + {"zcmop",&gcc_options::x_riscv_mop_subext, MASK_ZCMOP}, + {"zve32x", &gcc_options::x_target_flags, MASK_VECTOR}, {"zve32f", &gcc_options::x_target_flags, MASK_VECTOR}, {"zve64x", &gcc_options::x_target_flags, MASK_VECTOR}, diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index 2e340e5324ff..a8758abc9189 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -406,6 +406,13 @@ Mask(ZICBOP) Var(riscv_zicmo_subext) Mask(ZIC64B) Var(riscv_zicmo_subext) +TargetVariable +int riscv_mop_subext + +Mask(ZIMOP) Var(riscv_mop_subext) + +Mask(ZCMOP) Var(riscv_mop_subext) + TargetVariable int riscv_zf_subext diff --git a/gcc/testsuite/gcc.target/riscv/arch-42.c b/gcc/testsuite/gcc.target/riscv/arch-42.c new file mode 100644 index ..83f78d28dbe0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-42.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64i_zimop -mabi=lp64" } */ +int foo() +{ +} diff --git a/gcc/testsuite/gcc.target/riscv/arch-43.c b/gcc/testsuite/gcc.target/riscv/arch-43.c new file mode 100644 index ..4a300a165fd9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-43.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64i_zcmop -mabi=lp64" } */ +int foo() +{ +}