From 8efd8be0cefbf4f0dff1473a4b1077c571145197 Mon Sep 17 00:00:00 2001
From: Jonathan Yong <10walls@gmail.com>
Date: Tue, 8 Sep 2020 14:56:50 +0200
Subject: [PATCH 03/13] Cygwin: handle dllimport properly in medium model V2

---
 gcc/config/i386/predicates.md | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index b815aca0da7..c71eed7f60c 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -202,6 +202,7 @@
 	switch (XINT (XEXP (op, 0), 1))
 	  {
 	  case UNSPEC_GOTPCREL:
+	    if (TARGET_PECOFF) break;
 	  case UNSPEC_DTPOFF:
 	  case UNSPEC_GOTNTPOFF:
 	  case UNSPEC_NTPOFF:
@@ -307,6 +308,10 @@
       if (ix86_force_load_from_GOT_p (op))
 	return false;
 
+      /* Dll-imported symbols are always external.  */
+      if (TARGET_DLLIMPORT_DECL_ATTRIBUTES && SYMBOL_REF_DLLIMPORT_P (op))
+        return false;
+
      /* For certain code models, the symbolic references are known to fit.  */
       return (ix86_cmodel == CM_SMALL
 	      || (ix86_cmodel == CM_MEDIUM
-- 
2.39.0

