target dependent phase to improves memory accesses#229
Conversation
| && !riscv_compressed_lw_address_p (XEXP (x, 0))) | ||
| cost++; | ||
|
|
||
| *total = COSTS_N_INSNS (cost + tune_param->memory_cost); |
There was a problem hiding this comment.
i changed it back - was from prior code where i tried to change change instruction costs
| HOST_WIDE_INT scaled_offset = cumulative_inc << shift_amount; | ||
| confirm_change_group(); | ||
|
|
||
| validate_change(insn_addr, &XEXP(XEXP(and_rtx, 0), 0), root_reg, 1); |
There was a problem hiding this comment.
Why are you changing insn_addr, can't you use root_reg directly in new_mem_addr?
You also don't check if insn_addr is only used by insn, so you now break other uses.
There was a problem hiding this comment.
the insn_addr needs to pick the root of the chain of immediate additions so needs to be changed.
the output of insn_addr is not changed. I only change one of its inputs and the accumulation of the additions i pass it directly into the offset of the true dependent subsequent memory operations.
| } | ||
|
|
||
| basic_block bb; | ||
| FOR_EACH_BB_FN(bb, fun) { |
There was a problem hiding this comment.
What's the point of this? Can this be handled by cse or cprop passes instead?
There was a problem hiding this comment.
i tried placing the phase in various places where there were not available those after.
b7893f6 to
6effe87
Compare
4964de9 to
57972ac
Compare
f18b1d7 to
3f16af7
Compare
This phase identifies memory loads that use a base address calculated via instructions like sh1add. It traces the index register of that calculation back through previous instructions to find increments. As a result instead of having a separate instruction to increment followed by a pointer to scale and add it, this pass merges the constant offset directly into the memory load. Thus it reduces the total number of instructions leading to smaller code size and faster execution. I added also a test that checks if offsets > 0 are generated out memory accesses inside unrolled loops.
This phase identifies memory loads that use a base address calculated via instructions like sh1add. It traces the index register of that calculation back through previous instructions to find increments.
As a result instead of having a separate instruction to increment followed by a pointer to scale and add it, this pass merges the constant offset directly into the memory load. Thus it reduces the total number of instructions leading to smaller code size and faster execution.