diff --git a/ares/m4/cares-compilers.m4 b/ares/m4/cares-compilers.m4
index 8d0c069e63e47f2ab372f2ba45875acb7791c4df..eaf0cc2162988a17675c79e26dcb372823e5400e 100644
--- a/ares/m4/cares-compilers.m4
+++ b/ares/m4/cares-compilers.m4
@@ -224,12 +224,12 @@ AC_DEFUN([CARES_CHECK_COMPILER_SGI], [
   CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
   CURL_CHECK_DEF([__GNUC__], [], [silent])
   CURL_CHECK_DEF([__sgi], [], [silent])
-  if test "$curl_cv_have_def___GNUC__ " = "no"; then
+  if test "$curl_cv_have_def___GNUC__" = "no"; then
     if test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes"; then
       compiler_id="SGIC"
     fi
-    if test "$curl_cv_have_def__COMPILER_VERSION " = "yes" &&
-      test "$curl_cv_have_def___sgi " = "yes"; then
+    if test "$curl_cv_have_def__COMPILER_VERSION" = "yes" &&
+      test "$curl_cv_have_def___sgi" = "yes"; then
       compiler_id="SGIC"
     fi
   fi
diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4
index f15e9fb980fb1dc7b92ffd15509a1ad3574ca0bf..469801e69cda04385886d4a5dde236de25fc5326 100644
--- a/m4/curl-compilers.m4
+++ b/m4/curl-compilers.m4
@@ -230,12 +230,12 @@ AC_DEFUN([CURL_CHECK_COMPILER_SGI], [
   CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
   CURL_CHECK_DEF([__GNUC__], [], [silent])
   CURL_CHECK_DEF([__sgi], [], [silent])
-  if test "$curl_cv_have_def___GNUC__ " = "no"; then
+  if test "$curl_cv_have_def___GNUC__" = "no"; then
     if test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes"; then
       compiler_id="SGIC"
     fi
-    if test "$curl_cv_have_def__COMPILER_VERSION " = "yes" &&
-      test "$curl_cv_have_def___sgi " = "yes"; then
+    if test "$curl_cv_have_def__COMPILER_VERSION" = "yes" &&
+      test "$curl_cv_have_def___sgi" = "yes"; then
       compiler_id="SGIC"
     fi
   fi