Re: [PATCH v7] Implement new RTL optimizations pass: fold-mem-offsets.

2023-11-28 Thread Jeff Law
On 11/27/23 13:52, Jakub Jelinek wrote: On Mon, Oct 16, 2023 at 01:11:01PM -0600, Jeff Law wrote: 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 op

Re: [PATCH v7] Implement new RTL optimizations pass: fold-mem-offsets.

2023-11-28 Thread Manolis Tsamis
On Tue, Nov 28, 2023 at 12:53 PM Jakub Jelinek wrote: > > On Tue, Nov 28, 2023 at 11:45:58AM +0200, Manolis Tsamis wrote: > > > But, while get_single_def_in_bb checks for > > > if (DF_INSN_LUID (def) > DF_INSN_LUID (insn)) > > > return NULL; > > > (OT, why not DF_INSN_INFO_LUID (DF_REF_INSN_

Re: [PATCH v7] Implement new RTL optimizations pass: fold-mem-offsets.

2023-11-28 Thread Jakub Jelinek
On Tue, Nov 28, 2023 at 11:45:58AM +0200, Manolis Tsamis wrote: > > But, while get_single_def_in_bb checks for > > if (DF_INSN_LUID (def) > DF_INSN_LUID (insn)) > > return NULL; > > (OT, why not DF_INSN_INFO_LUID (DF_REF_INSN_INFO (ref_chain->ref)) > > instead of DF_INSN_LUID (def), then it d

Re: [PATCH v7] Implement new RTL optimizations pass: fold-mem-offsets.

2023-11-28 Thread Manolis Tsamis
Hi Jakub, Thanks a lot for tracking this down and providing both testcases and a fix. Some thoughts below. On Mon, Nov 27, 2023 at 10:52 PM Jakub Jelinek wrote: > > On Mon, Oct 16, 2023 at 01:11:01PM -0600, Jeff Law wrote: > > > gcc/ChangeLog: > > > > > > * Makefile.in: Add fold-mem-offsets.

Re: [PATCH v7] Implement new RTL optimizations pass: fold-mem-offsets.

2023-11-27 Thread Jakub Jelinek
On Mon, Oct 16, 2023 at 01:11:01PM -0600, Jeff Law wrote: > > 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: Docu

Re: [PATCH v7] Implement new RTL optimizations pass: fold-mem-offsets.

2023-10-16 Thread Jeff Law
On 10/16/23 12:01, Manolis Tsamis wrote: 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)

Re: [PATCH v7] Implement new RTL optimizations pass: fold-mem-offsets.

2023-10-16 Thread Manolis Tsamis
This version has been bootstrapped and tested to cause no regressions in both x86 and Aarch64. Manolis On Mon, Oct 16, 2023 at 9:01 PM Manolis Tsamis wrote: > > This is a new RTL pass that tries to optimize memory offset calculations > by moving them from add immediate instructions to the memory

[PATCH v7] Implement new RTL optimizations pass: fold-mem-offsets.

2023-10-16 Thread Manolis Tsamis
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