--- llvm-test-suite/HashProgramOutput.sh
+++ llvm-test-suite/HashProgramOutput.sh
@@ -8,11 +8,14 @@ fi
 md5cmd=$(which md5sum)
 is_md5sum=1
 if [ ! -x "$md5cmd" ]; then
-    md5cmd=$(which md5)
-    is_md5sum=0
+    md5cmd=$(which gmd5sum)
     if [ ! -x "$md5cmd" ]; then
-        echo "error: unable to find either 'md5sum' or 'md5'"
-        exit 1
+        md5cmd=$(which md5)
+        is_md5sum=0
+        if [ ! -x "$md5cmd" ]; then
+            echo "error: unable to find either 'md5sum' or 'md5'"
+            exit 1
+        fi
     fi
 fi
 
