When selecting a memory operation for which the only available D-Form instructions have alignment requirements for the displacement immediate, we end up having to select X-Form instructions if the immediate isn't a required multiple. However, if the base register is used for multiple memory operations, we don't need to be so pessimistic.
For example,
vector int test(char *Ptr) { vector int a = *(vector int *)(Ptr+7); vector int b = *(vector int *)(Ptr+23); vector int c = *(vector int *)(Ptr+39); vector int d = *(vector int *)(Ptr+55); return a + b + c + d; }
We currently materialize the constants 3, 7, 23, 39 in registers and use those as index registers with R3 as the base. However, if we computed the value r3 + 55, we can use DQ-Form instructions with displacements (48, 23, 16, 0).
This patch performs these adjustments and fixes up some of the addressing computation functions so as to avoid redundant code.
I am not sure the intention that you select the vector instead of map. The map make more sense to me.