diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index 19176b1b17940f50696ca579c22be509df709bc9..020c8939def00ca6b075255ee00d3fd3115758c7 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -26,6 +26,11 @@
 #include <sys/param.h>
 #endif
 
+#if defined(_M_AMD64) && _MSC_VER == 1800
+#include <math.h>
+#include <versionhelpers.h>
+#endif
+
 #include "bootstrap/bootstrap.h"
 #include "common/username.h"
 #include "postmaster/postmaster.h"
@@ -263,6 +268,22 @@ startup_hacks(const char *progname)
 
 		/* In case of general protection fault, don't show GUI popup box */
 		SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
+
+#if defined(_M_AMD64) && _MSC_VER == 1800
+		/*
+		 * Avoid crashing in certain floating-point operations if
+		 * we were compiled for x64 with MS Visual Studio 2013 and
+		 * are running on Windows prior to 7/2008R2 SP1 on an
+		 * AVX2-capable CPU.
+		 *
+		 * Ref: https://connect.microsoft.com/VisualStudio/feedback/details/811093/visual-studio-2013-rtm-c-x64-code-generation-bug-for-avx2-instructions
+		 */
+		if (!IsWindows7SP1OrGreater())
+		{
+			_set_FMA3_enable(0);
+		}
+#endif /* defined(_M_AMD64) && _MSC_VER == 1800 */
+
 	}
 #endif   /* WIN32 */