From 13e4f305e040097de34481a72756dbe0ebd06dbc Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Fri, 3 Nov 2017 14:59:39 +0000 Subject: [PATCH] RISC-V: Handle non-legitimate address in riscv_legitimize_move GCC may generate non-legitimate address due to we allow some load/store with non-legitimate address in pic.md. gcc/ChangeLog 2017-11-03 Kito Cheng * config/riscv/riscv.c (riscv_legitimize_move): Handle non-legitimate address. From-SVN: r254376 --- gcc/ChangeLog | 5 +++++ gcc/config/riscv/riscv.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 561e3dae7c9..bbfdfe2f818 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-11-03 Kito Cheng + + * config/riscv/riscv.c (riscv_legitimize_move): Handle + non-legitimate address. + 2017-11-03 Segher Boessenkool * config/rs6000/rs6000.md (*lt0_disi): Delete. diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index c34468e018d..b81a2d29fbf 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -1332,6 +1332,22 @@ riscv_legitimize_move (machine_mode mode, rtx dest, rtx src) return true; } + /* RISC-V GCC may generate non-legitimate address due to we provide some + pattern for optimize access PIC local symbol and it's make GCC generate + unrecognizable instruction during optmizing. */ + + if (MEM_P (dest) && !riscv_legitimate_address_p (mode, XEXP (dest, 0), + reload_completed)) + { + XEXP (dest, 0) = riscv_force_address (XEXP (dest, 0), mode); + } + + if (MEM_P (src) && !riscv_legitimate_address_p (mode, XEXP (src, 0), + reload_completed)) + { + XEXP (src, 0) = riscv_force_address (XEXP (src, 0), mode); + } + return false; } -- 2.30.2