@@ -5053,6 +5053,18 @@ mips_split_move_insn (rtx dest, rtx src, rtx insn)
mips_split_move (dest, src, mips_insn_split_type (insn));
}
+/* Return true if X is a GP-relative symbol in the constant pool.
+ CONTEXT is the context in which X appears. */
+
+bool
+mips_constant_pool_symbol_in_sdata_p (rtx x, enum mips_symbol_context context)
+{
+ enum mips_symbol_type symbol_type;
+ return (mips_symbolic_constant_p (x, context, &symbol_type)
+ && symbol_type == SYMBOL_GP_RELATIVE
+ && CONSTANT_POOL_ADDRESS_P (x));
+}
+
/* Return the appropriate instructions to move SRC into DEST. Assume
that SRC is operand 1 and DEST is operand 0. */
@@ -5202,7 +5214,13 @@ mips_output_move (rtx dest, rtx src)
}
if (src_code == HIGH)
- return TARGET_MIPS16 ? "#" : "lui\t%0,%h1";
+ {
+ if (mips_constant_pool_symbol_in_sdata_p (XEXP (src, 0),
+ SYMBOL_CONTEXT_MEM))
+ return "move\t%0,$28";
+
+ return TARGET_MIPS16 ? "#" : "lui\t%0,%h1";
+ }
if (CONST_GP_P (src))
return "move\t%0,%1";
new file mode 100644
@@ -0,0 +1,12 @@
+/* { dg-options "(-mips16) -G4 -mno-abicalls -mcode-readable=no" } */
+typedef struct { int a, b, c, d; } A[5000];
+int a, b;
+extern void bar (int, int, A);
+
+void
+foo (int p1)
+{
+ A c;
+ while (p1)
+ bar (a, b, c);
+}