Hi Suwa-san, On Mon, Jan 23, 2023 at 7:43 PM Takayuki 'January June' Suwa <jjsuwa_sys3...@yahoo.co.jp> wrote: > > Register-register move instructions that can be easily seen as > unnecessary by the human eye may remain in the compiled result. > For example: > > /* example */ > double test(double a, double b) { > return __builtin_copysign(a, b); > } > > test: > add.n a3, a3, a3 > extui a5, a5, 31, 1 > ssai 1 > ;; be in the same BB > src a7, a5, a3 ;; No '0' in the source constraints > ;; The destination replaced is > ;; irrelevant to the sources if the > ;; destination constraint has '&' > ;; No CALL insns in this span > ;; Both A3 and A7 are irrelevant to > ;; insns in this span > mov.n a3, a7 ;; An unnecessary reg-reg move > ;; A7 is not used after this > ret.n > > The last two instructions above, excluding the return instruction, > could be done like this: > > src a3, a5, a3 > > This symptom often occurs when handling DI/DFmode values with SImode > instructions. This patch solves the above problem using peephole2 > pattern. > > gcc/ChangeLog: > > * config/xtensa/xtensa.md: New peephole2 pattern that eliminates > the occurrence of general-purpose register used only once and for > transferring intermediate value. > > gcc/testsuite/ChangeLog: > > * gcc.target/xtensa/elim_GP_regmove.c: New. > --- > gcc/config/xtensa/xtensa.md | 49 +++++++++++++++++++ > .../gcc.target/xtensa/elim_GP_regmove.c | 23 +++++++++ > 2 files changed, 72 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/xtensa/elim_GP_regmove.c
This change breaks windowed builds by the following ICEs: libgcc/libgcov-interface.c: In function ‘__gcov_execlp’: libgcc/libgcov-interface.c:263:1: error: insn does not satisfy its constraints: 263 | } | ^ (insn 96 95 98 11 (set (reg/f:SI 1 sp) (minus:SI (reg/f:SI 1 sp) (reg:SI 8 a8 [85]))) "libgcc/libgcov-interface.c":253:20 4 {subsi3} (expr_list:REG_DEAD (reg:SI 8 a8 [85]) (nil))) during RTL pass: cprop_hardreg libgcc/libgcov-interface.c:263:1: internal compiler error: in extract_constrain_insn, at recog.cc:2692 It also introduces at least one regression in executable tests in call0 build, I haven't tracked it down yet. -- Thanks. -- Max