https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67573
Bug ID: 67573
Summary: [SH] wrong code generated for
libstdc++-v3/src/c++11/cxx11-shim_facets.cc at -mlra
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: kkojima at gcc dot gnu.org
CC: olegendo at gcc dot gnu.org
Blocks: 55212
Target Milestone: ---
Target: sh*-*-*
Wrong code is generated with sh-linux/sh-elf compilers for
void std::__facet_shims::__moneypunct_fill_cache<wchar_t,
true>(std::integral_constant<bool, true>, std::locale::facet const*,
std::__moneypunct_cache<wchar_t, true>*)
at "-m4 -ml -O2 -fPIC -mlra -std=gnu++11".
It uses __copy<wchar_t> inline function and __copy<wchar_t> calls
std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> >::copy(wchar_t*, unsigned int, unsigned int)
with the wrong code
mov r11,r4
mov.l .L1122,r7
mov r0,r5
mov.l @r15,r6
mov r10,r4
bsrf r7
.LPCS203:
mov.l r0,@(4,r15)
...
.L1122:
.long
_ZNKSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE4copyEPwjj@PLT-(.LPCS203+2-.)
where r7 should be 0 as the last argument. With -mno-lra,
the corresponding code is:
mov.l .L1050,r1
mov r0,r14
mov #0,r7
mov r13,r6
mov r0,r5
bsrf r1
.LPCS191:
mov r10,r4
...
It seems that dse/dce removes mov #0, r7.
.pro_and_epilogue:
(insn 204 831 830 22 (set (reg:SI 7 r7)
(const_int 0 [0])) fa.cc:484 253 {movsi_ie}
(nil))
.dse2 marks r7 unused:
(insn 204 831 830 22 (set (reg:SI 7 r7)
(const_int 0 [0])) fa.cc:484 253 {movsi_ie}
(expr_list:REG_UNUSED (reg:SI 7 r7)
(nil)))
.jump2 eliminates insn 204:
DCE: Deleting insn 204
deleting insn with uid = 204.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212
[Bug 55212] [SH] Switch to LRA