diff mbox series

[V2] RISC-V: XFAIL scan dump fails for autovec PR111311

Message ID 20231208233759.2732806-1-ewlu@rivosinc.com
State New
Headers show
Series [V2] RISC-V: XFAIL scan dump fails for autovec PR111311 | expand

Commit Message

Edwin Lu Dec. 8, 2023, 11:37 p.m. UTC
Clean up scan dump failures on linux rv64 vector targets Juzhe mentioned 
could be ignored for now. This will help reduce noise and make it more obvious
if a bug or regression is introduced. The failures that are still reported
are either execution failures or failures that are also present on armv8-a+sve

gcc/testsuite/ChangeLog:

	* c-c++-common/vector-subscript-4.c: xfail testcase
	* g++.dg/tree-ssa/pr83518.C: ditto
	* gcc.dg/attr-alloc_size-11.c: remove xfail
	* gcc.dg/signbit-2.c: xfail testcase
	* gcc.dg/signbit-5.c: ditto
	* gcc.dg/tree-ssa/cunroll-16.c: ditto
	* gcc.dg/tree-ssa/gen-vect-34.c: ditto
	* gcc.dg/tree-ssa/loop-bound-1.c: ditto
	* gcc.dg/tree-ssa/loop-bound-2.c: ditto
	* gcc.dg/tree-ssa/pr84512.c: remove xfail
	* gcc.dg/tree-ssa/predcom-4.c: xfail testcase
	* gcc.dg/tree-ssa/predcom-5.c: ditto
	* gcc.dg/tree-ssa/predcom-9.c: ditto
	* gcc.dg/tree-ssa/reassoc-46.c: ditto
	* gcc.dg/tree-ssa/scev-10.c: ditto
	* gcc.dg/tree-ssa/scev-11.c: ditto
	* gcc.dg/tree-ssa/scev-14.c: ditto
	* gcc.dg/tree-ssa/scev-9.c: ditto
	* gcc.dg/tree-ssa/split-path-11.c: ditto
	* gcc.dg/tree-ssa/ssa-dom-cse-2.c: ditto
	* gcc.dg/tree-ssa/update-threading.c: ditto
	* gcc.dg/unroll-8.c: ditto
	* gcc.dg/var-expand1.c: ditto
	* gcc.dg/vect/pr103116-1.c: ditto
	* gcc.dg/vect/pr103116-2.c: ditto
	* gcc.dg/vect/pr65310.c: ditto
	* gfortran.dg/vect/vect-8.f90: ditto
	* lib/target-supports.exp: ditto

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
---
V2 changes:
- added attr-alloc_size-11.c and update-threading.c which were missed in
  previous patch
- remove pr83232.f90 xfail since it was fixed in a recent trunk update
- adjust xfail on split-path-11.c to only apply to rv64
---
 gcc/testsuite/c-c++-common/vector-subscript-4.c  | 3 ++-
 gcc/testsuite/g++.dg/tree-ssa/pr83518.C          | 2 +-
 gcc/testsuite/gcc.dg/attr-alloc_size-11.c        | 4 ++--
 gcc/testsuite/gcc.dg/signbit-2.c                 | 5 +++--
 gcc/testsuite/gcc.dg/signbit-5.c                 | 1 +
 gcc/testsuite/gcc.dg/tree-ssa/cunroll-16.c       | 5 +++--
 gcc/testsuite/gcc.dg/tree-ssa/gen-vect-34.c      | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/loop-bound-1.c     | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/loop-bound-2.c     | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/pr84512.c          | 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/predcom-4.c        | 5 +++--
 gcc/testsuite/gcc.dg/tree-ssa/predcom-5.c        | 5 +++--
 gcc/testsuite/gcc.dg/tree-ssa/predcom-9.c        | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c       | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/scev-10.c          | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/scev-11.c          | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/scev-14.c          | 4 +++-
 gcc/testsuite/gcc.dg/tree-ssa/scev-9.c           | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/split-path-11.c    | 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-2.c    | 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/update-threading.c | 2 +-
 gcc/testsuite/gcc.dg/unroll-8.c                  | 8 +++++---
 gcc/testsuite/gcc.dg/var-expand1.c               | 3 ++-
 gcc/testsuite/gcc.dg/vect/pr103116-1.c           | 3 ++-
 gcc/testsuite/gcc.dg/vect/pr103116-2.c           | 3 ++-
 gcc/testsuite/gcc.dg/vect/pr65310.c              | 4 ++--
 gcc/testsuite/gfortran.dg/vect/vect-8.f90        | 3 ++-
 gcc/testsuite/lib/target-supports.exp            | 3 +++
 28 files changed, 59 insertions(+), 34 deletions(-)

Comments

Kito Cheng Dec. 11, 2023, 5:37 a.m. UTC | #1
> diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr83518.C b/gcc/testsuite/g++.dg/tree-ssa/pr83518.C
> index b8a2bd1ebbd..6f2fc56c82c 100644
> --- a/gcc/testsuite/g++.dg/tree-ssa/pr83518.C
> +++ b/gcc/testsuite/g++.dg/tree-ssa/pr83518.C
> @@ -24,4 +24,4 @@ unsigned test()
>    return sum;
>  }
>
> -/* { dg-final { scan-tree-dump "return 15;" "optimized" { xfail vect_variable_length } } } */
> +/* { dg-final { scan-tree-dump "return 15;" "optimized" { xfail { vect_variable_length && aarch64*-*-* } } } } */

aarch64?
Edwin Lu Dec. 11, 2023, 6:35 p.m. UTC | #2
On 12/10/2023 9:37 PM, Kito Cheng wrote:
>> diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr83518.C b/gcc/testsuite/g++.dg/tree-ssa/pr83518.C
>> index b8a2bd1ebbd..6f2fc56c82c 100644
>> --- a/gcc/testsuite/g++.dg/tree-ssa/pr83518.C
>> +++ b/gcc/testsuite/g++.dg/tree-ssa/pr83518.C
>> @@ -24,4 +24,4 @@ unsigned test()
>>     return sum;
>>   }
>>
>> -/* { dg-final { scan-tree-dump "return 15;" "optimized" { xfail vect_variable_length } } } */
>> +/* { dg-final { scan-tree-dump "return 15;" "optimized" { xfail { vect_variable_length && aarch64*-*-* } } } } */
> aarch64?

I found the patch which added the xfail vect_variable_length originating 
from https://inbox.sourceware.org/gcc-patches/mptfszz8vxw.fsf@arm.com/. 
The patch mentioned how it was tested on aarch64 which is why I added 
it. Should I change it to ! riscv_v?

Edwin
diff mbox series

Patch

diff --git a/gcc/testsuite/c-c++-common/vector-subscript-4.c b/gcc/testsuite/c-c++-common/vector-subscript-4.c
index 2c2481f88b7..eb0bca1c19e 100644
--- a/gcc/testsuite/c-c++-common/vector-subscript-4.c
+++ b/gcc/testsuite/c-c++-common/vector-subscript-4.c
@@ -25,5 +25,6 @@  foobar(16)
 foobar(32)
 foobar(64)
 
+/* Xfail riscv PR112531.  */
 /* Verify we don't have any vector temporaries in the IL.  */
-/* { dg-final { scan-tree-dump-not "vector" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "vector" "optimized" { xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr83518.C b/gcc/testsuite/g++.dg/tree-ssa/pr83518.C
index b8a2bd1ebbd..6f2fc56c82c 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr83518.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr83518.C
@@ -24,4 +24,4 @@  unsigned test()
   return sum;
 }
 
-/* { dg-final { scan-tree-dump "return 15;" "optimized" { xfail vect_variable_length } } } */
+/* { dg-final { scan-tree-dump "return 15;" "optimized" { xfail { vect_variable_length && aarch64*-*-* } } } } */
diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-11.c b/gcc/testsuite/gcc.dg/attr-alloc_size-11.c
index a2efe128915..2828db12e05 100644
--- a/gcc/testsuite/gcc.dg/attr-alloc_size-11.c
+++ b/gcc/testsuite/gcc.dg/attr-alloc_size-11.c
@@ -47,8 +47,8 @@  typedef __SIZE_TYPE__    size_t;
 
 /* The following tests fail because of missing range information.  The xfail
    exclusions are PR79356.  */
-TEST (signed char, SCHAR_MIN + 2, ALLOC_MAX);   /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for signed char" { xfail { ! { aarch64*-*-* arm*-*-* avr-*-* alpha*-*-* cris-*-* ia64-*-* mips*-*-* or1k*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390*-*-* visium-*-* msp430-*-* nvptx*-*-*} } } } */
-TEST (short, SHRT_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for short" { xfail { ! { aarch64*-*-* arm*-*-* alpha*-*-* avr-*-* cris-*-* ia64-*-* mips*-*-* or1k*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390x-*-* visium-*-* msp430-*-* nvptx*-*-* } } } } */
+TEST (signed char, SCHAR_MIN + 2, ALLOC_MAX);   /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for signed char" { xfail { ! { aarch64*-*-* arm*-*-* avr-*-* alpha*-*-* cris-*-* ia64-*-* mips*-*-* or1k*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390*-*-* visium-*-* msp430-*-* nvptx*-*-* riscv*-*-* } } } } */
+TEST (short, SHRT_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for short" { xfail { ! { aarch64*-*-* arm*-*-* alpha*-*-* avr-*-* cris-*-* ia64-*-* mips*-*-* or1k*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390x-*-* visium-*-* msp430-*-* nvptx*-*-* riscv*-*-* } } } } */
 TEST (int, INT_MIN + 2, ALLOC_MAX);    /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */
 TEST (int, -3, ALLOC_MAX);             /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */
 TEST (int, -2, ALLOC_MAX);             /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */
diff --git a/gcc/testsuite/gcc.dg/signbit-2.c b/gcc/testsuite/gcc.dg/signbit-2.c
index 62bb4047d74..2a32568de9e 100644
--- a/gcc/testsuite/gcc.dg/signbit-2.c
+++ b/gcc/testsuite/gcc.dg/signbit-2.c
@@ -22,6 +22,7 @@  void fun2(int32_t *x, int n)
 }
 
 /* Xfail amdgcn where vector truth type is not integer type.  */
-/* { dg-final { scan-tree-dump {\s+>\s+\{ 0(, 0)+ \}} optimized { target vect_shift xfail amdgcn-*-* } } } */
+/* Xfail riscv PR111311.  */
+/* { dg-final { scan-tree-dump {\s+>\s+\{ 0(, 0)+ \}} optimized { target vect_shift xfail { amdgcn-*-* || { riscv_v && vect_variable_length } } } } } */
 /* { dg-final { scan-tree-dump {\s+>\s+0} optimized { target { ! vect_shift } } } } */
-/* { dg-final { scan-tree-dump-not {\s+>>\s+31} optimized { xfail amdgcn-*-* } } } */
+/* { dg-final { scan-tree-dump-not {\s+>>\s+31} optimized { xfail { amdgcn-*-* || { riscv_v && vect_variable_length } } } } } */
diff --git a/gcc/testsuite/gcc.dg/signbit-5.c b/gcc/testsuite/gcc.dg/signbit-5.c
index 0fad56c0ea8..becf8b45aa8 100644
--- a/gcc/testsuite/gcc.dg/signbit-5.c
+++ b/gcc/testsuite/gcc.dg/signbit-5.c
@@ -4,6 +4,7 @@ 
 /* This test does not work when the truth type does not match vector type.  */
 /* { dg-additional-options "-mno-avx512f" { target { i?86-*-* x86_64-*-* } } } */
 /* { dg-additional-options "-march=armv8-a" { target aarch64_sve } } */
+/* { dg-additional-options "-fwrapv" { target riscv_v } } */
 /* { dg-xfail-run-if "truth type does not match vector type" { amdgcn-*-* } } */
 
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-16.c b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-16.c
index 9bb66ff8299..53bb75e9c17 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-16.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-16.c
@@ -13,5 +13,6 @@  int main() {
     foo();
 }
 
-/* { dg-final { scan-tree-dump "optimized: loop with \[0-9\]\+ iterations completely unrolled" "cunroll" } } */
-/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */
+/* Xfail riscv PR111311.  */
+/* { dg-final { scan-tree-dump "optimized: loop with \[0-9\]\+ iterations completely unrolled" "cunroll" { xfail { riscv_v && vect_variable_length } } } } */
+/* { dg-final { scan-tree-dump-not "foo" "optimized" { xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-34.c b/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-34.c
index c2e5dfea35f..49b59f6d8d7 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-34.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-34.c
@@ -13,4 +13,5 @@  float summul(int n, float *arg1, float *arg2)
     return res1;                                       
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_masked_load } } } */
+/* Xfail riscv PR111311.  */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_masked_load xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-bound-1.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-bound-1.c
index aedcac2103a..022a8a00ad2 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-bound-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-bound-1.c
@@ -17,6 +17,7 @@  foo (unsigned char s, unsigned char l)
   return sum;
 }
 
+/* Xfail riscv PR111311.  */
 /* Check loop niter bound information.  */
-/* { dg-final { scan-tree-dump "bounded by 254" "ivopts" } } */
+/* { dg-final { scan-tree-dump "bounded by 254" "ivopts" { xfail { riscv_v && vect_variable_length } } } } */
 /* { dg-final { scan-tree-dump-not "bounded by 255" "ivopts" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-bound-2.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-bound-2.c
index 802dd290e50..06ccb1d7029 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-bound-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-bound-2.c
@@ -17,7 +17,8 @@  foo (signed char s, signed char l)
   return sum;
 }
 
+/* Xfail riscv PR111311.  */
 /* Check loop niter bound information.  */
-/* { dg-final { scan-tree-dump "bounded by 254" "ivopts" } } */
+/* { dg-final { scan-tree-dump "bounded by 254" "ivopts" {xfail { riscv_v && vect_variable_length } } } } */
 /* { dg-final { scan-tree-dump-not "bounded by 255" "ivopts" } } */
 /* { dg-final { scan-tree-dump-not "zero if " "ivopts" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr84512.c b/gcc/testsuite/gcc.dg/tree-ssa/pr84512.c
index 496c78b28dc..4ec8cbb69b4 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr84512.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr84512.c
@@ -13,4 +13,4 @@  int foo()
 }
 
 /* Listed targets xfailed due to PR84958.  */
-/* { dg-final { scan-tree-dump "return 285;" "optimized" { xfail { amdgcn*-*-* || vect_variable_length } } } } */
+/* { dg-final { scan-tree-dump "return 285;" "optimized" { xfail { amdgcn*-*-* || { aarch64*-*-* && vect_variable_length } } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-4.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-4.c
index af9ae0e0f3d..351243c3d24 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/predcom-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-4.c
@@ -24,6 +24,7 @@  int main(void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "Combination" 1 "pcom"} } */
-/* { dg-final { scan-tree-dump-times "Unrolling 3 times." 1 "pcom"} } */
+/* Xfail riscv PR112531.  */
+/* { dg-final { scan-tree-dump-times "Combination" 1 "pcom" { xfail { riscv_v && vect_variable_length } } } } */
+/* { dg-final { scan-tree-dump-times "Unrolling 3 times." 1 "pcom" { xfail { riscv_v && vect_variable_length } } } } */
 /* { dg-final { scan-tree-dump-not "Invalid sum" "pcom" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-5.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-5.c
index 52adb59d669..d35363d1942 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/predcom-5.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-5.c
@@ -24,6 +24,7 @@  int main(void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "Combination" 2 "pcom"} } */
-/* { dg-final { scan-tree-dump-times "Unrolling 3 times." 1 "pcom"} } */
+/* Xfail riscv PR112531.  */
+/* { dg-final { scan-tree-dump-times "Combination" 2 "pcom" { xfail { riscv_v && vect_variable_length } } } } */
+/* { dg-final { scan-tree-dump-times "Unrolling 3 times." 1 "pcom" { xfail { riscv_v && vect_variable_length } } } } */
 /* { dg-final { scan-tree-dump-not "Invalid sum" "pcom" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-9.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-9.c
index b0fb0e2d4c5..2c0b9af846e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/predcom-9.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-9.c
@@ -16,5 +16,6 @@  void foo (void)
     }
 }
 
+/* Xfail riscv PR112531.  */
 /* { dg-final { scan-tree-dump-not "Sinking # VUSE" "sink1" } } */
-/* { dg-final { scan-tree-dump "Executing predictive commoning without unrolling" "pcom" } } */
+/* { dg-final { scan-tree-dump "Executing predictive commoning without unrolling" "pcom" { xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c
index 97563dd929f..37bfe28213f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-46.c
@@ -3,5 +3,6 @@ 
 
 #include "reassoc-46.h"
 
+/* Xfail riscv PR112531.  */
 /* Check that the loop accumulator is added last.  */
-/* { dg-final { scan-tree-dump-times {(?:vect_)?sum_[\d._]+ = (?:(?:vect_)?_[\d._]+ \+ (?:vect_)?sum_[\d._]+|(?:vect_)?sum_[\d._]+ \+ (?:vect_)?_[\d._]+)} 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times {(?:vect_)?sum_[\d._]+ = (?:(?:vect_)?_[\d._]+ \+ (?:vect_)?sum_[\d._]+|(?:vect_)?sum_[\d._]+ \+ (?:vect_)?_[\d._]+)} 1 "optimized" { xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/scev-10.c b/gcc/testsuite/gcc.dg/tree-ssa/scev-10.c
index ba111914b3c..a1b43932b49 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/scev-10.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/scev-10.c
@@ -17,6 +17,7 @@  foo (signed char s, signed char l)
   return sum;
 }
 
+/* Xfail riscv PR112531.  */
 /* Address of array reference is scev.  */
-/* { dg-final { scan-tree-dump-times "  Type:\\tREFERENCE ADDRESS\n" 1 "ivopts" } } */
+/* { dg-final { scan-tree-dump-times "  Type:\\tREFERENCE ADDRESS\n" 1 "ivopts" { xfail { riscv_v && vect_variable_length } } } } */
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/scev-11.c b/gcc/testsuite/gcc.dg/tree-ssa/scev-11.c
index f15688538ea..c7ec60acc7c 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/scev-11.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/scev-11.c
@@ -22,5 +22,6 @@  foo (int n)
   return 0;
 }
 
+/* Xfail riscv PR112531.  */
 /* Address of array reference to b is scev.  */
-/* { dg-final { scan-tree-dump-times "  Type:\\tREFERENCE ADDRESS\n" 2 "ivopts" } } */
+/* { dg-final { scan-tree-dump-times "  Type:\\tREFERENCE ADDRESS\n" 2 "ivopts" { xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/scev-14.c b/gcc/testsuite/gcc.dg/tree-ssa/scev-14.c
index d7865fea24a..323a870c9d6 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/scev-14.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/scev-14.c
@@ -7,4 +7,6 @@  void t(unsigned int n)
   for (i=0; i<n; i++)
      a[i]++;
 }
-/* { dg-final { scan-tree-dump "Overflowness wrto loop niter:	No-overflow"  "ivopts" } } */
+
+/* Xfail riscv PR112531.  */
+/* { dg-final { scan-tree-dump "Overflowness wrto loop niter:	No-overflow"  "ivopts" {xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/scev-9.c b/gcc/testsuite/gcc.dg/tree-ssa/scev-9.c
index cbd7c85edfa..2358975a05b 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/scev-9.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/scev-9.c
@@ -17,6 +17,7 @@  foo (unsigned char s, unsigned char l)
   return sum;
 }
 
+/* Xfail riscv PR112531.  */
 /* Address of array reference is scev.  */
-/* { dg-final { scan-tree-dump-times "  Type:\\tREFERENCE ADDRESS\n" 1 "ivopts" } } */
+/* { dg-final { scan-tree-dump-times "  Type:\\tREFERENCE ADDRESS\n" 1 "ivopts" {xfail { riscv_v && vect_variable_length } } } } */
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/split-path-11.c b/gcc/testsuite/gcc.dg/tree-ssa/split-path-11.c
index 66f57d92edb..88bbf90ab51 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/split-path-11.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/split-path-11.c
@@ -11,4 +11,4 @@  void foo(unsigned long long *M)
     }
 }
 
-/* { dg-final { scan-tree-dump-times "join point for if-convertable half-diamond" 1 "split-paths" } } */
+/* { dg-final { scan-tree-dump-times "join point for if-convertable half-diamond" 1 "split-paths" { xfail { riscv_v && { vect_variable_length && lp64 } } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-2.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-2.c
index 5c89e3f8698..2261daa3940 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-2.c
@@ -27,4 +27,4 @@  foo ()
    but the loop reads only one element at a time, and DOM cannot resolve these.
    The same happens on powerpc depending on the SIMD support available.  */
 
-/* { dg-final { scan-tree-dump "return 28;" "optimized" { xfail { { alpha*-*-* hppa*64*-*-* nvptx*-*-* mmix-knuth-mmixware } || { { { lp64 && { powerpc*-*-* sparc*-*-* } } || aarch64_sve } || { arm*-*-* && { ! arm_neon } } } } } } } */
+/* { dg-final { scan-tree-dump "return 28;" "optimized" { xfail { { { alpha*-*-* hppa*64*-*-* nvptx*-*-* mmix-knuth-mmixware } || { { { lp64 && { powerpc*-*-* sparc*-*-* } } || aarch64_sve } || { arm*-*-* && { ! arm_neon } } } } || { riscv*-*-* && { ! riscv_v } } } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c b/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c
index 9500099cddf..dae405b86ec 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c
@@ -20,4 +20,4 @@  main (int argc, char **argv)
     foo (((A) { ((!(i >> 4) ? 8 : 64 + (i >> 4)) << 8) + (i << 4) } ).a);
   exit (0);
 }
-/* { dg-final { scan-tree-dump-times "Invalid sum" 0 "optimized" { xfail cris-*-* } } } Xfail: PR110628 */
+/* { dg-final { scan-tree-dump-times "Invalid sum" 0 "optimized" { xfail { cris-*-* riscv*-*-* } } } } Xfail: PR110628 */
diff --git a/gcc/testsuite/gcc.dg/unroll-8.c b/gcc/testsuite/gcc.dg/unroll-8.c
index 4388f47d4c7..231ffffade7 100644
--- a/gcc/testsuite/gcc.dg/unroll-8.c
+++ b/gcc/testsuite/gcc.dg/unroll-8.c
@@ -9,9 +9,11 @@  int t(struct a *a, int n)
   for (i=0;i<n;i++)
     a->a[i]++;
 }
+
+/* Xfail riscv PR112531.  */
 /* { dg-final { scan-rtl-dump-not "Unrolled loop" "loop2_unroll" } } */
-/* { dg-final { scan-rtl-dump "likely upper bound: 6" "loop2_unroll" } } */
-/* { dg-final { scan-rtl-dump "realistic bound: -1" "loop2_unroll" } } */
-/* { dg-final { scan-rtl-dump "Not unrolling loop, doesn't roll" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump "likely upper bound: 6" "loop2_unroll" { xfail { riscv_v && vect_variable_length } } } } */
+/* { dg-final { scan-rtl-dump "realistic bound: -1" "loop2_unroll" { xfail { riscv_v && vect_variable_length } } } } */
+/* { dg-final { scan-rtl-dump "Not unrolling loop, doesn't roll" "loop2_unroll" { xfail { riscv_v && vect_variable_length } } } } */
 /* { dg-final { scan-rtl-dump-not "Invalid sum" "loop2_unroll" } } */
 /* { dg-final { scan-rtl-dump-not "upper bound: -1" "loop2_unroll" } } */
diff --git a/gcc/testsuite/gcc.dg/var-expand1.c b/gcc/testsuite/gcc.dg/var-expand1.c
index 3d536cef2b3..eb7b6aeb18b 100644
--- a/gcc/testsuite/gcc.dg/var-expand1.c
+++ b/gcc/testsuite/gcc.dg/var-expand1.c
@@ -25,4 +25,5 @@  int main (void)
   return foo (10);
 }
 
-/* { dg-final { scan-rtl-dump "Expanding Accumulator" "loop2_unroll" } } */
+/* Xfail riscv PR111311.  */
+/* { dg-final { scan-rtl-dump "Expanding Accumulator" "loop2_unroll" { xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr103116-1.c b/gcc/testsuite/gcc.dg/vect/pr103116-1.c
index d3639fc8cfd..4c7eb9be199 100644
--- a/gcc/testsuite/gcc.dg/vect/pr103116-1.c
+++ b/gcc/testsuite/gcc.dg/vect/pr103116-1.c
@@ -47,4 +47,5 @@  main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "Data access with gaps requires scalar epilogue loop" "vect" { target { vect_perm && vect_int } } } } */
+/* Xfail riscv PR112531.  */
+/* { dg-final { scan-tree-dump "Data access with gaps requires scalar epilogue loop" "vect" { target { vect_perm && vect_int } xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr103116-2.c b/gcc/testsuite/gcc.dg/vect/pr103116-2.c
index aa9797a9407..1d070de1fe9 100644
--- a/gcc/testsuite/gcc.dg/vect/pr103116-2.c
+++ b/gcc/testsuite/gcc.dg/vect/pr103116-2.c
@@ -56,4 +56,5 @@  main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "peeling for gaps insufficient for access" "vect" { target { vect_perm_short } } } } */
+/* Xfail riscv PR112531.  */
+/* { dg-final { scan-tree-dump "peeling for gaps insufficient for access" "vect" { target { vect_perm_short } xfail { riscv_v && vect_variable_length } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr65310.c b/gcc/testsuite/gcc.dg/vect/pr65310.c
index 57e90d45c9f..63a9c987a6b 100644
--- a/gcc/testsuite/gcc.dg/vect/pr65310.c
+++ b/gcc/testsuite/gcc.dg/vect/pr65310.c
@@ -18,5 +18,5 @@  int t(b *a)
 /* The memory access is through a pointer of type c which means
    *ptr is not aligned.  */
 
-/* { dg-final { scan-tree-dump "can't force alignment" "vect" { xfail vect_element_align_preferred } } } */
-/* { dg-final { scan-tree-dump-not "misalign = 0" "vect" { xfail vect_element_align_preferred } } } */
+/* { dg-final { scan-tree-dump "can't force alignment" "vect" { xfail { vect_element_align_preferred || { riscv*-*-* && { ! riscv_v } } } } } } */
+/* { dg-final { scan-tree-dump-not "misalign = 0" "vect" { xfail { vect_element_align_preferred || { riscv*-*-* && { ! riscv_v } } } } } } */
diff --git a/gcc/testsuite/gfortran.dg/vect/vect-8.f90 b/gcc/testsuite/gfortran.dg/vect/vect-8.f90
index ca72ddcffca..75bd78db1ce 100644
--- a/gcc/testsuite/gfortran.dg/vect/vect-8.f90
+++ b/gcc/testsuite/gfortran.dg/vect/vect-8.f90
@@ -704,7 +704,8 @@  CALL track('KERNEL  ')
 RETURN
 END SUBROUTINE kernel
 
+! Xfail riscv PR112531. 
 ! { dg-final { scan-tree-dump-times "vectorized 25 loops" 1 "vect" { target aarch64_sve } } }
 ! { dg-final { scan-tree-dump-times "vectorized 24 loops" 1 "vect" { target { aarch64*-*-* && { ! aarch64_sve } } } } }
-! { dg-final { scan-tree-dump-times "vectorized 2\[234\] loops" 1 "vect" { target { vect_intdouble_cvt && { ! aarch64*-*-* } } } } }
+! { dg-final { scan-tree-dump-times "vectorized 2\[234\] loops" 1 "vect" { target { vect_intdouble_cvt && { ! aarch64*-*-* } } xfail { riscv_v && vect_variable_length } } } }
 ! { dg-final { scan-tree-dump-times "vectorized 17 loops" 1 "vect" { target { { ! vect_intdouble_cvt } && { ! aarch64*-*-* } } } } }
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 40a60c198cf..f99ae5578c2 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1898,6 +1898,9 @@  proc check_effective_target_riscv_d { } {
 # Cache the result.
 
 proc check_effective_target_riscv_v { } {
+    if { ![istarget riscv*-*-*] } {
+	return 0
+    }
     return [check_no_compiler_messages riscv_ext_v assembly {
        #ifndef __riscv_v
        #error "Not __riscv_v"