We need an temporary register when moving data from a cached memory to
an uncached memory. Fix this issue and add a test for it.
gcc/
2020-12-29 Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc.c (prepare_move_operands): Use a temporary
registers when we have cached mem-to-uncached mem moves.
gcc/testsuite/
2020-12-29 Vladimir Isaev <isaev@synopsys.com>
* gcc.target/arc/uncached-9.c: New test.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
}
if (arc_is_uncached_mem_p (operands[1]))
{
+ rtx tmp = operands[0];
+
if (MEM_P (operands[0]))
- operands[0] = force_reg (mode, operands[0]);
+ tmp = gen_reg_rtx (mode);
+
emit_insn (gen_rtx_SET
- (operands[0],
+ (tmp,
gen_rtx_UNSPEC_VOLATILE
(mode, gen_rtvec (1, operands[1]),
VUNSPEC_ARC_LDDI)));
+ if (MEM_P (operands[0]))
+ {
+ operands[1] = tmp;
+ return false;
+ }
return true;
}
}
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include <stdlib.h>
+
+struct uncached_st
+{
+ int value;
+} __attribute__((uncached));
+
+struct cached_st
+{
+ int value;
+};
+
+struct uncached_st g_uncached_st =
+ {
+ .value = 17
+ };
+
+struct cached_st g_cached_st =
+ {
+ .value = 4
+ };
+
+void __attribute__((noinline)) test_struct_copy (void)
+{
+ g_cached_st.value = g_uncached_st.value;
+}
+
+int main (void)
+{
+ test_struct_copy();
+
+ if (g_cached_st.value != g_uncached_st.value)
+ abort ();
+
+ return 0;
+}