On Mon, Jul 10, 2023 at 12:37 AM Hans-Peter Nilsson <h...@bitrange.com> wrote: > > On Thu, 15 Jun 2023, 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) > > 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. > > It punts on all "use" insns that are not SET. > Why not use single_set there too? >
The issue was that single_set will potentially discard clobbers, but if we have any clobbers it may be invalid to propagate through that instruction. Rejecting anything that is not a SET is enough to handle anything strange. Although this can be improved (look through clobbers/use?) the implementation will be more complicated without any obvious (large) benefit. Manolis > brgds, H-P