fi
 
 if [ $abi -eq 0 ]; then
-  abi=""
+  abiflag=""
 elif [ $abi -gt 0 -a $abi -lt 10 ]; then
-  abi="-DEXTENDEDTESTS=$((abi-1))"
+  abiflag="-DEXTENDEDTESTS=$((abi-1))"
 else
   echo "Error: The -a argument must be a value between 0 and 9 (inclusive)." >&2
   exit 1
 fi
 
 fail() {
-  echo "FAIL: $src $type $abi ($*)" | tee -a "$sum" "$log"
+  echo "FAIL: $src $type $abiflag ($*)" | tee -a "$sum" "$log"
+}
+
+xpass() {
+  echo "XPASS: $src $type $abiflag ($*)" | tee -a "$sum" "$log"
+}
+
+xfail() {
+  $quiet || echo "XFAIL: $src $type $abiflag ($*)"
+  echo "XFAIL: $src $type $abiflag ($*)" >> "$sum"
+  echo "XFAIL: $src $type $abiflag ($*)" >> "$log"
 }
 
 pass() {
-  $quiet || echo "PASS: $src $type $abi ($*)"
-  echo "PASS: $src $type $abi ($*)" >> "$sum"
-  echo "PASS: $src $type $abi ($*)" >> "$log"
+  $quiet || echo "PASS: $src $type $abiflag ($*)"
+  echo "PASS: $src $type $abiflag ($*)" >> "$sum"
+  echo "PASS: $src $type $abiflag ($*)" >> "$log"
 }
 
 unsupported() {
-  $quiet || echo "UNSUPPORTED: $src $type $abi ($*)"
-  echo "UNSUPPORTED: $src $type $abi ($*)" >> "$sum"
-  echo "UNSUPPORTED: $src $type $abi ($*)" >> "$log"
+  $quiet || echo "UNSUPPORTED: $src $type $abiflag ($*)"
+  echo "UNSUPPORTED: $src $type $abiflag ($*)" >> "$sum"
+  echo "UNSUPPORTED: $src $type $abiflag ($*)" >> "$log"
 }
 
 verify_compilation() {
       elif ! $quiet; then
         grep -i 'warning:' "$log" | head -n5
       fi
+    elif [ "$xfail" = "compile" ]; then
+      xpass "test for excess errors"
     else
       pass "test for excess errors"
     fi
       fail "timeout: test for excess errors"
     else
       errors=$(grep -ic 'error:' "$log")
-      fail "excess errors:" $errors
+      if [ "$xfail" = "compile" ]; then
+        xfail "excess errors:" $errors
+        exit 0
+      else
+        fail "excess errors:" $errors
+      fi
     fi
     if $verbose; then
       cat "$log"
   failed=$1
   if [ $failed -eq 0 ]; then
     rm "$exe"
-    pass "execution test"
+    if [ "$xfail" = "run" ]; then
+      xpass "execution test"
+    else
+      pass "execution test"
+    fi
   else
     $keep_failed || rm "$exe"
     if [ $failed -eq 124 ]; then
       fail "timeout: execution test"
+    elif [ "$xfail" = "run" ]; then
+      xfail "execution test"
+      exit 0
     else
       fail "execution test"
     fi
   fi
 }
 
+matches() {
+  eval "case '$1' in
+    $2) return 0;; esac"
+  return 1
+}
+
+test_selector() {
+  string="$1"
+  pat_type="${string%% *}"
+  if matches "$shorttype" "$pat_type"; then
+    string="${string#* }"
+    pat_abi="${string%% *}"
+    if matches "$abi" "$pat_abi"; then
+      string="${string#* }"
+      pat_triplet="${string%% *}"
+      [ -z "$target_triplet" ] && target_triplet=$($CXX -dumpmachine)
+      if matches "$target_triplet" "$pat_triplet"; then
+        pat_flags="${string#* }"
+        if matches "$CXXFLAGS" "$pat_flags"; then
+          return 0
+        fi
+      fi
+    fi
+  fi
+  return 1
+}
+
 rm -f "$log" "$sum"
 touch "$log" "$sum"
 
-if ! $run_expensive && [ -n "$abi" ]; then
-  unsupported "skip expensive tests"
-  exit 0
+skip="$(head -n25 "$src" | grep '^//\s*skip: ')"
+if [ -n "$skip" ]; then
+  skip="$(echo "$skip" | sed -e 's/^.*:\s*//' -e 's/ \+/ /g')"
+  if test_selector "$skip"; then
+    # silently skip this test
+    exit 0
+  fi
+fi
+only="$(head -n25 "$src" | grep '^//\s*only: ')"
+if [ -n "$only" ]; then
+  only="$(echo "$only" | sed -e 's/^.*:\s*//' -e 's/ \+/ /g')"
+  if ! test_selector "$only"; then
+    # silently skip this test
+    exit 0
+  fi
+fi
+if ! $run_expensive; then
+  expensive="$(head -n25 "$src" | grep '^//\s*expensive: ')"
+  if [ -n "$expensive" ]; then
+    expensive="$(echo "$expensive" | sed -e 's/^.*:\s*//' -e 's/ \+/ /g')"
+    if test_selector "$expensive"; then
+      unsupported "skip expensive tests"
+      exit 0
+    fi
+  fi
+fi
+xfail="$(head -n25 "$src" | grep '^//\s*xfail: ')"
+if [ -n "$xfail" ]; then
+  xfail="$(echo "$xfail" | sed -e 's/^.*:\s*//' -e 's/ \+/ /g')"
+  if test_selector "${xfail#* }"; then
+    xfail="${xfail%% *}"
+  else
+    unset xfail
+  fi
 fi
 
-write_log_and_verbose "$CXX $src $@ -D_GLIBCXX_SIMD_TESTTYPE=$type $abi -o $exe"
-timeout $timeout "$CXX" "$src" "$@" "-D_GLIBCXX_SIMD_TESTTYPE=$type" $abi -o "$exe" >> "$log" 2>&1
+write_log_and_verbose "$CXX $src $@ -D_GLIBCXX_SIMD_TESTTYPE=$type $abiflag -o $exe"
+timeout $timeout "$CXX" "$src" "$@" "-D_GLIBCXX_SIMD_TESTTYPE=$type" $abiflag -o "$exe" >> "$log" 2>&1
 verify_compilation $?
 if [ -n "$sim" ]; then
   write_log_and_verbose "$sim ./$exe"
 
 simd_testsuite.sum: simd_testsuite.log
        @printf "\n\t\t=== simd_testsuite \$(TESTFLAGS) Summary ===\n\n"\\
        "# of expected passes:\t\t\$(shell grep -c '^PASS:' \$@)\n"\\
+       "# of unexpected passes:\t\t\$(shell grep -c '^XPASS:' \$@)\n"\\
        "# of unexpected failures:\t\$(shell grep -c '^FAIL:' \$@)\n"\\
+       "# of expected failures:\t\t\$(shell grep -c '^XFAIL:' \$@)\n"\\
        "# of unsupported tests:\t\t\$(shell grep -c '^UNSUPPORTED:' \$@)\n"\\
          | tee -a \$@
 
 EOF
 
+matches() {
+  eval "case '$1' in
+    $2) return 0;; esac"
+  return 1
+}
+
+cxx_type() {
+  case "$1" in
+    ldouble) echo "long double";;
+    ullong)  echo "unsigned long long";;
+    ulong)   echo "unsigned long";;
+    llong)   echo "long long";;
+    uint)    echo "unsigned int";;
+    ushort)  echo "unsigned short";;
+    uchar)   echo "unsigned char";;
+    schar)   echo "signed char";;
+    *)       echo "$1";;
+  esac
+}
+
+filter_types() {
+  only="$1"
+  skip="$2"
+  shift 2
+  if [ -z "$only" -a -z "$skip" ]; then
+    for x in "$@"; do
+      cxx_type "$x"
+      echo "$x"
+    done
+  elif [ -z "$skip" ]; then
+    for x in "$@"; do
+      if matches "$x" "$only"; then
+        cxx_type "$x"
+        echo "$x"
+      fi
+    done
+  elif [ -z "$only" ]; then
+    for x in "$@"; do
+      matches "$x" "$skip" && continue
+      cxx_type "$x"
+      echo "$x"
+    done
+  else
+    for x in "$@"; do
+      matches "$x" "$skip" && continue
+      if matches "$x" "$only"; then
+        cxx_type "$x"
+        echo "$x"
+      fi
+    done
+  fi
+}
+
 all_types() {
   src="$1"
-  cat <<EOF
-long double
-ldouble
-double
-double
-float
-float
-EOF
-  ([ -n "$src" ] && grep -q "test only floattypes" "$src") || \
-  cat <<EOF
-long long
-llong
-unsigned long long
-ullong
-unsigned long
-ulong
-long
-long
-int
-int
-unsigned int
-uint
-short
-short
-unsigned short
-ushort
-char
-char
-signed char
-schar
-unsigned char
-uchar
-char32_t
-char32_t
-char16_t
-char16_t
-wchar_t
-wchar_t
-EOF
+  only=
+  skip=
+  if [ -n "$src" ]; then
+    only="$(head -n25 "$src"| grep '^//\s*only: [^ ]* \* \* \*')"
+    only="${only#*: }"
+    only="${only%% *}"
+    skip="$(head -n25 "$src"| grep '^//\s*skip: [^ ]* \* \* \*')"
+    skip="${skip#*: }"
+    skip="${skip%% *}"
+  fi
+  filter_types "$only" "$skip" \
+    "ldouble" \
+    "double" \
+    "float" \
+    "llong" \
+    "ullong" \
+    "ulong" \
+    "long" \
+    "int" \
+    "uint" \
+    "short" \
+    "ushort" \
+    "char" \
+    "schar" \
+    "uchar" \
+    "char32_t" \
+    "char16_t" \
+    "wchar_t"
 }
 
 all_tests() {
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include <cmath>    // abs & sqrt
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/conversions.h"
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/test_values.h"
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/test_values.h"
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/test_values.h"
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/make_vec.h"
 #include "bits/metahelpers.h"
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/test_values.h"
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/make_vec.h"
 #include "bits/conversions.h"
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/mathreference.h"
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 
 namespace stdx = std::experimental;
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 
 // simd_mask generator functions
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/test_values.h"
 
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/test_values.h"
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/make_vec.h"
 #include "bits/test_values.h"
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/test_values.h"
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/test_values.h"
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 
 template <typename V>
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// xfail: run * * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/mathreference.h"
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/conversions.h"
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 
 template <typename V>
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/metahelpers.h"
 #include "bits/test_values.h"
 
-// test only floattypes
 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// only: float|double|ldouble * * *
+// expensive: * [1-9] * *
 #include "bits/test_values.h"
 #include "bits/verify.h"
 
 
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// expensive: * [1-9] * *
 #include "bits/verify.h"
 #include "bits/make_vec.h"
 #include "bits/metahelpers.h"