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/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/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..95e6b16ce89 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,5 @@ void foo(unsigned long long *M)
     }
 }
 
-/* { dg-final { scan-tree-dump-times "join point for if-convertable half-diamond" 1 "split-paths" } } */
+/* Xfail riscv PR112531.  */
+/* { dg-final { scan-tree-dump-times "join point for if-convertable half-diamond" 1 "split-paths" { xfail { riscv_v && vect_variable_length } } } } */
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/gfortran.dg/vect/pr83232.f90 b/gcc/testsuite/gfortran.dg/vect/pr83232.f90
index af883421be1..3de81956c66 100644
--- a/gcc/testsuite/gfortran.dg/vect/pr83232.f90
+++ b/gcc/testsuite/gfortran.dg/vect/pr83232.f90
@@ -27,7 +27,8 @@
       call foo (Einc)
       END SUBROUTINE
 
+! Xfail riscv PR112531. 
 ! We should vectorize (1), (2) and (3) under vect_hw_misalign.
-! { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "slp1" { target vect_hw_misalign } } }
+! { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "slp1" { target vect_hw_misalign xfail { riscv_v && vect_variable_length } } } }
 ! But only (1) and (3) under !vect_hw_misalign due to the alignment of (2).
 ! { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "slp1" { target { ! vect_hw_misalign } } } }
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*-*-* } } } } }
