aa8fd7f656
Under the LA architecture, when the stack is dropped too far, the process of dropping the stack is divided into two steps. step1: After dropping the stack, save callee saved registers on the stack. step2: The rest of it. The stack drop operation is optimized when frame->total_size minus frame->sp_fp_offset is an integer multiple of 4096, can reduce the number of instructions required to drop the stack. However, this optimization is not effective because of the original calculation method The following case: int main() { char buf[1024 * 12]; printf ("%p\n", buf); return 0; } As you can see from the generated assembler, the old GCC has two more instructions than the new GCC, lines 14 and line 24. new old 10 main: | 11 main: 11 addi.d $r3,$r3,-16 | 12 lu12i.w $r13,-12288>>12 12 lu12i.w $r13,-12288>>12 | 13 addi.d $r3,$r3,-2032 13 lu12i.w $r5,-12288>>12 | 14 ori $r13,$r13,2016 14 lu12i.w $r12,12288>>12 | 15 lu12i.w $r5,-12288>>12 15 st.d $r1,$r3,8 | 16 lu12i.w $r12,12288>>12 16 add.d $r12,$r12,$r5 | 17 st.d $r1,$r3,2024 17 add.d $r3,$r3,$r13 | 18 add.d $r12,$r12,$r5 18 add.d $r5,$r12,$r3 | 19 add.d $r3,$r3,$r13 19 la.local $r4,.LC0 | 20 add.d $r5,$r12,$r3 20 bl %plt(printf) | 21 la.local $r4,.LC0 21 lu12i.w $r13,12288>>12 | 22 bl %plt(printf) 22 add.d $r3,$r3,$r13 | 23 lu12i.w $r13,8192>>12 23 ld.d $r1,$r3,8 | 24 ori $r13,$r13,2080 24 or $r4,$r0,$r0 | 25 add.d $r3,$r3,$r13 25 addi.d $r3,$r3,16 | 26 ld.d $r1,$r3,2024 26 jr $r1 | 27 or $r4,$r0,$r0 | 28 addi.d $r3,$r3,2032 | 29 jr $r1 gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_compute_frame_info): Modify fp_sp_offset and gp_sp_offset's calculation method, when frame->mask or frame->fmask is zero, don't minus UNITS_PER_WORD or UNITS_PER_FP_REG. gcc/testsuite/ChangeLog: * gcc.target/loongarch/prolog-opt.c: New test. |
||
---|---|---|
INSTALL | ||
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libiberty | ||
libitm | ||
libobjc | ||
liboffloadmic | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
COPYING | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
COPYING3 | ||
COPYING3.LIB | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
README | ||
ar-lib | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
lt~obsolete.m4 | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
symlink-tree | ||
test-driver | ||
ylwrap |
README
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.