Hi! After some attemptions, I think we still ne to check "check_effective_target_loongarch_sx" in vect_int_mod. I wrote some temp logics in gcc/testsuite/lib/target-supports.exp like this:
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 2de41cef2f6..91e1c22a6e1 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -8586,7 +8586,8 @@ proc check_effective_target_vect_int_mod { } { return [check_cached_effective_target_indexed vect_int_mod { expr { ([istarget powerpc*-*-*] && [check_effective_target_has_arch_pwr10]) - || [istarget amdgcn-*-*] }}] + || [istarget loongarch*-*-*] + || [istarget amdgcn-*-*] }}] } # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise. @@ -11174,6 +11175,12 @@ proc check_vect_support_and_set_flags { } { lappend DEFAULT_VECTCFLAGS "--param" "riscv-vector-abi" set dg-do-what-default compile } + } elseif [istarget loongarch*-*-*] { + if [check_effective_target_loongarch_asx_hw] { + lappend DEFAULT_VECTCFLAGS "-mdouble-float" "-mlasx" + } elseif [check_effective_target_loongarch_sx_hw] { + lappend DEFAULT_VECTCFLAGS "-mdouble-float" "-mlsx" + } } else { return 0 } \* temp impl of sx/asx hw proc *\ And then in make check without --target_board=unix/-mlasx, vect.exp is invoked with expected vector isa options, but pr104992.c failed because it expected result with "vect_int_mod returns 1" but it was compiled without -mlsx/-mlasx. Seems pr104992.c is invoked by gcc.dg/dg.exp, pr104992.c is not affected by DEFAULT_CFLAGS, so we still need to check if LSX/LASX is available in vect_int_mod. Other parts of new patch is still WIP. On Sun, 2023-09-24 at 18:05 +0800, Xi Ruoyao wrote: > On Wed, 2023-09-20 at 09:15 +0800, Chenghui Pan wrote: > > LoongArch failed to pass gcc.dg/pr104992.c with -mlsx and -mlasx. > > This test uses > > different dg-final directives depending on the vect_int_mod result, > > LoongArch > > SX/ASX supports this operations but corresponding description is > > not defined in > > target-supports.exp. This patch solves the problem above with some > > modification in proc check_effective_target_vect_int_mod. > > I think we can just add -mdouble-float -mlasx into DEFAULT_VECTCFLAGS > and always enable vect_int_mod for LoongArch. This will make > vect.exp > tests automatically run for every "make check" on LoongArch. > > > gcc/testsuite/ChangeLog: > > > > * lib/target-supports.exp: Update > > check_effective_target_vect_int_mod according to > > LoongArch SX/ASX capabilities. > > --- > > gcc/testsuite/lib/target-supports.exp | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/gcc/testsuite/lib/target-supports.exp > > b/gcc/testsuite/lib/target-supports.exp > > index 2de41cef2f6..b253dc578d2 100644 > > --- a/gcc/testsuite/lib/target-supports.exp > > +++ b/gcc/testsuite/lib/target-supports.exp > > @@ -8586,6 +8586,8 @@ proc check_effective_target_vect_int_mod { } > > { > > return [check_cached_effective_target_indexed vect_int_mod { > > expr { ([istarget powerpc*-*-*] > > && [check_effective_target_has_arch_pwr10]) > > + || ([istarget loongarch*-*-*] > > + && [check_effective_target_loongarch_sx]) > > || [istarget amdgcn-*-*] }}] > > } > > > > @@ -12656,6 +12658,22 @@ proc > > check_effective_target_const_volatile_readonly_section { } { > > return 1 > > } > > > > +proc check_effective_target_loongarch_sx { } { > > + return [check_no_compiler_messages loongarch_lsx assembly { > > + #if !defined(__loongarch_sx) > > + #error "LSX not defined" > > + #endif > > + }] > > +} > > + > > +proc check_effective_target_loongarch_asx { } { > > + return [check_no_compiler_messages loongarch_asx assembly { > > + #if !defined(__loongarch_asx) > > + #error "LASX not defined" > > + #endif > > + }] > > +} > > + > > # Appends necessary Python flags to extra-tool-flags if Python.h > > is supported. > > # Otherwise, modifies dg-do-what. > > proc dg-require-python-h { args } { >