diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 46cce9b8445e5760c850e4cabc888f162fd353ad..089c2bba9fc3e60dfbf2705a1dc4d7c40fe6a762 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -354,9 +354,9 @@ proc libgomp_check_effective_target_offload_target { target_name } {
     # decides.  This is somewhat modelled after
     # 'gcc/testsuite/lib/target-supports.exp:check_configured_with'.
     set gcc_output [libgomp_target_compile "" "" "none" $options]
-    if [regexp "(?n)^OFFLOAD_TARGET_NAMES=(.*)" $gcc_output dummy offload_targets] {
-	verbose "compiling for offload targets: $offload_targets"
-	return [string match "*:$target_name*:*" ":$offload_targets:"]
+    if [regexp "(?n)^OFFLOAD_TARGET_NAMES=(.*)" $gcc_output dummy gcc_offload_targets] {
+	verbose "compiling for offload targets: $gcc_offload_targets"
+	return [string match "*:$target_name*:*" ":$gcc_offload_targets:"]
     }
 
     verbose "not compiling for $target_name offload target"