Find a file
Roger Sayle 3ceb109fcb ARC: Split SImode shifts pre-reload on !TARGET_BARREL_SHIFTER.
This patch splits SImode shifts, for !TARGET_BARREL_SHIFTER targets,
after combine and before reload, in the split1 pass, as suggested by
the FIXME comment above output_shift in arc.cc.  To do this I've
copied the implementation of the x86_pre_reload_split function from
the i386 backend, and renamed it arc_pre_reload_split.

Although the actual implementations of shifts remain the same
(as in output_shift), having them as explicit instructions in
the RTL stream allows better scheduling and use of compact forms
when available.  The benefits can be seen in two short examples
below.

For the function:
unsigned int foo(unsigned int x, unsigned int y) {
  return y << 2;
}

GCC with -O2 -mcpu=em would previously generate:
foo:    add r1,r1,r1
        add r1,r1,r1
        j_s.d   [blink]
        mov_s   r0,r1   ;4
and with this patch now generates:
foo:    asl_s r0,r1
        j_s.d   [blink]
        asl_s r0,r0

Notice the original (from shift_si3's output_shift) requires the
shift sequence to be monolithic with the same destination register
as the source (requiring an extra mov_s).  The new version can
eliminate this move, and schedule the second asl in the branch
delay slot of the return.

For the function:
int x,y,z;

void bar()
{
  x <<= 3;
  y <<= 3;
  z <<= 3;
}

GCC -O2 -mcpu=em currently generates:
bar:	push_s  r13
        ld.as   r12,[gp,@x@sda] ;23
        ld.as   r3,[gp,@y@sda]  ;23
        mov r2,0
        add3 r12,r2,r12
        mov r2,0
        add3 r3,r2,r3
        ld.as   r2,[gp,@z@sda]  ;23
        st.as   r12,[gp,@x@sda] ;26
        mov r13,0
        add3 r2,r13,r2
        st.as   r3,[gp,@y@sda]  ;26
        st.as   r2,[gp,@z@sda]  ;26
        j_s.d   [blink]
        pop_s   r13

where each shift by 3, uses ARC's add3 instruction, which is similar
to x86's lea implementing x = (y<<3) + z, but requires the value zero
to be placed in a temporary register "z".  Splitting this before reload
allows these pseudos to be shared/reused.  With this patch, we get

bar:	ld.as   r2,[gp,@x@sda]  ;23
        mov_s   r3,0    ;3
        add3    r2,r3,r2
        ld.as   r3,[gp,@y@sda]  ;23
        st.as   r2,[gp,@x@sda]  ;26
        ld.as   r2,[gp,@z@sda]  ;23
        mov_s   r12,0   ;3
        add3    r3,r12,r3
        add3    r2,r12,r2
        st.as   r3,[gp,@y@sda]  ;26
        st.as   r2,[gp,@z@sda]  ;26
        j_s     [blink]

Unfortunately, register allocation means that we only share two of the
three "mov_s z,0", but this is sufficient to reduce register pressure
enough to avoid spilling r13 in the prologue/epilogue.

2023-10-04  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* config/arc/arc-protos.h (emit_shift): Delete prototype.
	(arc_pre_reload_split): New function prototype.
	* config/arc/arc.cc (emit_shift): Delete function.
	(arc_pre_reload_split): New predicate function, copied from i386,
	to schedule define_insn_and_split splitters to the split1 pass.
	* config/arc/arc.md (ashlsi3): Expand RTL template unconditionally.
	(ashrsi3): Likewise.
	(lshrsi3): Likewise.
	(shift_si3): Move after other shift patterns, and disable when
	operands[2] is one (which is handled by its own define_insn).
	Use shiftr4_operator, instead of shift4_operator, as this is no
	longer used for left shifts.
	(shift_si3_loop): Likewise.  Additionally remove match_scratch.
	(*ashlsi3_nobs): New pre-reload define_insn_and_split.
	(*ashrsi3_nobs): Likewise.
	(*lshrsi3_nobs): Likewise.
	(rotrsi3_cnt1): Rename define_insn from *rotrsi3_cnt1.
	(add_shift): Rename define_insn from *add_shift.
	* config/arc/predicates.md (shiftl4_operator): Delete.
	(shift4_operator): Delete.

gcc/testsuite/ChangeLog
	* gcc.target/arc/ashrsi-1.c: New TARGET_BARREL_SHIFTER test case.
	* gcc.target/arc/ashrsi-2.c: New !TARGET_BARREL_SHIFTER test case.
	* gcc.target/arc/ashrsi-3.c: Likewise.
	* gcc.target/arc/ashrsi-4.c: Likewise.
	* gcc.target/arc/ashrsi-5.c: Likewise.
	* gcc.target/arc/lshrsi-1.c: New TARGET_BARREL_SHIFTER test case.
	* gcc.target/arc/lshrsi-2.c: New !TARGET_BARREL_SHIFTER test case.
	* gcc.target/arc/lshrsi-3.c: Likewise.
	* gcc.target/arc/lshrsi-4.c: Likewise.
	* gcc.target/arc/lshrsi-5.c: Likewise.
	* gcc.target/arc/shlsi-1.c: New TARGET_BARREL_SHIFTER test case.
	* gcc.target/arc/shlsi-2.c: New !TARGET_BARREL_SHIFTER test case.
	* gcc.target/arc/shlsi-3.c: Likewise.
	* gcc.target/arc/shlsi-4.c: Likewise.
	* gcc.target/arc/shlsi-5.c: Likewise.
2023-10-04 17:17:03 +01:00
c++tools Daily bump. 2023-06-23 00:16:38 +00:00
config Daily bump. 2023-09-16 00:17:55 +00:00
contrib Daily bump. 2023-10-04 00:17:41 +00:00
fixincludes Daily bump. 2023-08-18 00:16:52 +00:00
gcc ARC: Split SImode shifts pre-reload on !TARGET_BARREL_SHIFTER. 2023-10-04 17:17:03 +01:00
gnattools Daily bump. 2023-04-26 00:17:46 +00:00
gotools Daily bump. 2022-08-31 00:16:45 +00:00
include Daily bump. 2023-08-23 00:17:59 +00:00
INSTALL
intl Daily bump. 2023-08-08 00:17:37 +00:00
libada Daily bump. 2023-08-08 00:17:37 +00:00
libatomic Daily bump. 2023-08-08 00:17:37 +00:00
libbacktrace Daily bump. 2023-08-08 00:17:37 +00:00
libcc1 Daily bump. 2023-08-12 00:17:36 +00:00
libcody Daily bump. 2023-06-16 00:17:18 +00:00
libcpp Daily bump. 2023-09-21 00:17:49 +00:00
libdecnumber Daily bump. 2023-06-16 00:17:18 +00:00
libffi Daily bump. 2023-08-24 00:18:18 +00:00
libgcc Daily bump. 2023-09-28 09:50:12 +00:00
libgfortran Daily bump. 2023-09-29 00:17:28 +00:00
libgm2 Daily bump. 2023-09-30 00:17:24 +00:00
libgo libgo: fix DejaGNU testsuite compiler when using build sysroot 2023-09-12 13:19:42 -07:00
libgomp libgomp.texi: Clarify that no other OpenMP context selectors are implemented 2023-10-04 14:52:34 +02:00
libiberty Daily bump. 2023-08-23 00:17:59 +00:00
libitm Daily bump. 2023-08-08 00:17:37 +00:00
libobjc Daily bump. 2023-08-08 00:17:37 +00:00
libphobos Daily bump. 2023-09-24 00:16:58 +00:00
libquadmath Daily bump. 2023-08-08 00:17:37 +00:00
libsanitizer Daily bump. 2023-08-08 00:17:37 +00:00
libssp Daily bump. 2023-08-08 00:17:37 +00:00
libstdc++-v3 libstdc++: _versioned_namespace is always non-None 2023-10-04 08:23:30 -06:00
libvtv Daily bump. 2023-08-08 00:17:37 +00:00
lto-plugin Daily bump. 2023-08-08 00:17:37 +00:00
maintainer-scripts Daily bump. 2023-07-08 00:16:53 +00:00
zlib Daily bump. 2023-08-08 00:17:37 +00:00
.dir-locals.el
.gitattributes
.gitignore .gitignore: do not ignore config.h 2022-07-19 17:07:04 +03:00
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2023-09-19 00:17:49 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in LoongArch: Reimplement multilib build option handling. 2023-09-15 10:42:12 +08:00
config.guess
config.rpath
config.sub config.sub: change mode to 755. 2021-12-21 09:10:57 +01:00
configure LoongArch: Reimplement multilib build option handling. 2023-09-15 10:42:12 +08:00
configure.ac LoongArch: Reimplement multilib build option handling. 2023-09-15 10:42:12 +08:00
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
depcomp
install-sh
libtool-ldflags
libtool.m4 libtool.m4: augment symcode for Solaris 11 2023-08-07 22:59:41 +02:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS MAINTAINERS: Add myself to write after approval 2023-09-18 09:43:54 +00:00
Makefile.def toplevel: Makefile.def: add install-strip dependency on libsframe 2023-08-07 22:59:42 +02:00
Makefile.in Pass 'SYSROOT_CFLAGS_FOR_TARGET' down to target libraries [PR109951] 2023-09-12 11:30:37 +02:00
Makefile.tpl Pass 'SYSROOT_CFLAGS_FOR_TARGET' down to target libraries [PR109951] 2023-09-12 11:30:37 +02:00
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

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.