diff options
author | Claudiu Zissulescu <claziss@synopsys.com> | 2020-12-29 13:30:04 +0200 |
---|---|---|
committer | Claudiu Zissulescu <claziss@synopsys.com> | 2020-12-29 13:41:03 +0200 |
commit | e51727c6912c0b0190b3bd8f64e711e2eecbc045 (patch) | |
tree | 766acd260ba477bf7a90f923e2af9a5c2c1097d9 | |
parent | 052870c3d1c962a0875c4debc066ccc3d68e7029 (diff) | |
download | gcc-e51727c6912c0b0190b3bd8f64e711e2eecbc045.zip gcc-e51727c6912c0b0190b3bd8f64e711e2eecbc045.tar.gz gcc-e51727c6912c0b0190b3bd8f64e711e2eecbc045.tar.bz2 |
arc: Fix cached to uncached moves.
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>
-rw-r--r-- | gcc/config/arc/arc.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/arc/uncached-9.c | 39 |
2 files changed, 49 insertions, 2 deletions
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 6a9e1fb..d0a52ee 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -9234,13 +9234,21 @@ prepare_move_operands (rtx *operands, machine_mode mode) } 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; } } diff --git a/gcc/testsuite/gcc.target/arc/uncached-9.c b/gcc/testsuite/gcc.target/arc/uncached-9.c new file mode 100644 index 0000000..4caba29 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/uncached-9.c @@ -0,0 +1,39 @@ +/* { 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; +} |