+2020-05-02  Tom de Vries  <tdevries@suse.de>
+
+       * lib/gdb.exp (supports_mpx_check_pointer_bounds): New proc.
+       * gdb.arch/i386-mpx-call.exp: Use supports_mpx_check_pointer_bounds.
+       * gdb.arch/i386-mpx-map.exp: Same.
+       * gdb.arch/i386-mpx-sigsegv.exp: Same.
+       * gdb.arch/i386-mpx-simple_segv.exp: Same.
+       * gdb.arch/i386-mpx.exp: Same.
+
 2020-05-02  Tom de Vries  <tdevries@suse.de>
 
        * gdb.base/psym-external-decl.c (main): Add use of variable aaa.
 
 
 standard_testfile
 
+if { ![supports_mpx_check_pointer_bounds] } {
+    return -1
+}
+
 set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat"
 
 if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 
 
 standard_testfile
 
+if { ![supports_mpx_check_pointer_bounds] } {
+    return -1
+}
+
 set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 
 
 standard_testfile
 
+if { ![supports_mpx_check_pointer_bounds] } {
+    return -1
+}
+
 set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 
 
 standard_testfile
 
+if { ![supports_mpx_check_pointer_bounds] } {
+    return -1
+}
+
 set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 
     return
 }
 
+if { ![supports_mpx_check_pointer_bounds] } {
+    return -1
+}
+
 set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 
     } executable "additional_flags=-gstatement-frontiers"]
 }
 
+# Return 1 if compiler supports -mmpx -fcheck-pointer-bounds.  Otherwise,
+# return 0.
+
+gdb_caching_proc supports_mpx_check_pointer_bounds {
+    set flags "additional_flags=-mmpx additional_flags=-fcheck-pointer-bounds"
+    return [gdb_can_simple_compile supports_mpx_check_pointer_bounds {
+       int main () {
+           return 0;
+       }
+    } executable $flags]
+}
+
 # Return 1 if symbols were read in using -readnow.  Otherwise, return 0.
 
 proc readnow { } {