aboutsummaryrefslogtreecommitdiff
path: root/gcc/passes.def
diff options
context:
space:
mode:
authorManolis Tsamis <manolis.tsamis@vrull.eu>2023-10-16 13:08:12 -0600
committerJeff Law <jlaw@ventanamicro.com>2023-10-16 13:08:57 -0600
commit04c9cf5c786b94fbe3f6f21f06cae73a7575ff7a (patch)
tree9bea307c51146c9ac3324b16f57d56e958db64e5 /gcc/passes.def
parent964fd402c9b48eb4da91fb3e4e45d4560d6c676c (diff)
downloadgcc-04c9cf5c786b94fbe3f6f21f06cae73a7575ff7a.zip
gcc-04c9cf5c786b94fbe3f6f21f06cae73a7575ff7a.tar.gz
gcc-04c9cf5c786b94fbe3f6f21f06cae73a7575ff7a.tar.bz2
Implement new RTL optimizations pass: fold-mem-offsets
This is a new RTL pass that tries to optimize memory offset calculations by moving them from add immediate instructions to the memory loads/stores. For example it can transform this: addi t4,sp,16 add t2,a6,t4 shl t3,t2,1 ld a2,0(t3) addi a2,1 sd a2,8(t2) into the following (one instruction less): add t2,a6,sp shl t3,t2,1 ld a2,32(t3) addi a2,1 sd a2,24(t2) Although there are places where this is done already, this pass is more powerful and can handle the more difficult cases that are currently not optimized. Also, it runs late enough and can optimize away unnecessary stack pointer calculations. gcc/ChangeLog: * Makefile.in: Add fold-mem-offsets.o. * passes.def: Schedule a new pass. * tree-pass.h (make_pass_fold_mem_offsets): Declare. * common.opt: New options. * doc/invoke.texi: Document new option. * fold-mem-offsets.cc: New file. gcc/testsuite/ChangeLog: * gcc.target/riscv/fold-mem-offsets-1.c: New test. * gcc.target/riscv/fold-mem-offsets-2.c: New test. * gcc.target/riscv/fold-mem-offsets-3.c: New test. * gcc.target/i386/pr52146.c: Adjust expected output. Signed-off-by: Manolis Tsamis <manolis.tsamis@vrull.eu>
Diffstat (limited to 'gcc/passes.def')
-rw-r--r--gcc/passes.def1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/passes.def b/gcc/passes.def
index 2bafd60..df7965d 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -519,6 +519,7 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_peephole2);
NEXT_PASS (pass_if_after_reload);
NEXT_PASS (pass_regrename);
+ NEXT_PASS (pass_fold_mem_offsets);
NEXT_PASS (pass_cprop_hardreg);
NEXT_PASS (pass_fast_rtl_dce);
NEXT_PASS (pass_reorder_blocks);