<div dir="ltr">Hi,<div><br></div><div>I have a question on how I would support load/store instructions where the offset is automatically scaled by the type. Simply put, any array index would be scaled by the width, so that there no longer needs to be a separate </div><div><br></div><div>int32_t arr = {...}</div><div>for (int i = 0; i < 100. i++) {</div><div>   x += arr[i]</div><div>}</div><div><br></div><div>the llvm code of (code below approximation of what would showup)</div><div>%a = ld i32 %arr_ptr, %offset</div><div>%x = add i32 %x %a</div><div>%offset = offset + 4</div><div>%i = %i + 1</div><div>%cond  = icmp %i 100 ICMP_ULT</div><div>br for.body</div><div><br></div><div>would lower to:</div><div><br></div><div><div>%a = ld i32 %arr_ptr, %i</div><div>%x = add i32 %x %a</div><div><span style="line-height:1.5">%i = %i + 1</span><br></div><div>%cond  = icmp %i 100 ICMP_ULT</div></div><div><div>br for.body</div><br class="inbox-inbox-Apple-interchange-newline"></div><div>Right now, the only idea I would have is to replace getelementptr instructions with an intrinsic that computes the offset and pass that in to the load instruction, and in instruction selection look for patterns of loads with intrinsic, and convert that to a scaled_arr load.</div><div><br></div><div>Sorry if what I am asking is somewhat confusing.</div><div>-Dilan</div><div><br></div></div>