From 6b3790d183decea78d75f8d12fe6cd9f9a09ad4b Mon Sep 17 00:00:00 2001
From: Jonathan Yong <10walls@gmail.com>
Date: Tue, 8 Sep 2020 14:56:50 +0200
Subject: [PATCH 05/18] 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 71f4cb1193c..d43708b9e90 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -180,6 +180,7 @@
 	switch (XINT (XEXP (op, 0), 1))
 	  {
 	  case UNSPEC_GOTPCREL:
+	    if (TARGET_PECOFF) break;
 	  case UNSPEC_DTPOFF:
 	  case UNSPEC_GOTNTPOFF:
 	  case UNSPEC_NTPOFF:
@@ -282,6 +283,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.28.0

