diff --git a/gas/config/.Sanitize b/gas/config/.Sanitize
index 547f8bc657e..21590737d6f 100644
--- a/gas/config/.Sanitize
+++ b/gas/config/.Sanitize
@@ -15,6 +15,10 @@
 
 Do-first:
 
+if [ -d vms ]; then
+	lose_these_too="vms ${lose_these_too}"
+fi
+
 d30v_files="tc-d30v.c tc-d30v.h"
 
 if ( echo $* | grep keep\-d30v > /dev/null ) ; then
@@ -166,8 +170,6 @@ vms-a-conf.h
 
 Things-to-lose:
 
-vms
-
 Do-last:
 
 r5900_files="tc-mips.c"
diff --git a/gas/testsuite/gas/.Sanitize b/gas/testsuite/gas/.Sanitize
index 197c98a4669..229b497e40a 100644
--- a/gas/testsuite/gas/.Sanitize
+++ b/gas/testsuite/gas/.Sanitize
@@ -17,6 +17,12 @@
 
 Do-first:
 
+for d in gasp i386-bsd ieee.fp mn10x00 ; do
+	if [ -d $d ]; then
+		lose_these_too="$d ${lose_these_too}"
+	fi
+done
+
 if ( echo $* | grep keep\-tic80 > /dev/null ) ; then
 	keep_these_too="tic80 ${keep_these_too}"
 else
@@ -64,11 +70,6 @@ vax
 
 Things-to-lose:
 
-gasp
-i386-bsd
-ieee.fp
-mn10x00
-
 Do-last:
 
 # End of file.