diff --git a/external/gpl3/gcc/dist/gcc/expmed.c b/external/gpl3/gcc/dist/gcc/expmed.c
index b9f12576b0cf..b3da32a7a764 100644
--- a/external/gpl3/gcc/dist/gcc/expmed.c
+++ b/external/gpl3/gcc/dist/gcc/expmed.c
@@ -39,6 +39,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "explow.h"
 #include "expr.h"
 #include "langhooks.h"
+#include "recog.h"
 
 struct target_expmed default_target_expmed;
 #if SWITCHABLE_TARGET
@@ -5408,7 +5409,10 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1,
      convert the comparison into one involving a single word.  */
   if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD * 2
       && GET_MODE_CLASS (mode) == MODE_INT
-      && (!MEM_P (op0) || ! MEM_VOLATILE_P (op0)))
+      && (!MEM_P (op0) || ! MEM_VOLATILE_P (op0))
+      && ( ! (MEM_P (op0) &&
+              mode_dependent_address_p (XEXP (op0, 0), MEM_ADDR_SPACE (op0))) )
+      )
     {
       rtx tem;
       if ((code == EQ || code == NE)
