<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57771>57771</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            WASM: Array lookups (and other dynamic accesses) don't use the offset of load/store
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          d0sboots
      </td>
    </tr>
</table>

<pre>
    https://godbolt.org/z/ajTs7EEoj

```
char data[] = "Hello world";

char test1(int idx) {
  return data[0];
}

char test2(int idx) {
  return data[idx];
}
```

Compiling with `-S -target wasm32 -Os` gives (filtered):
```
test1:                                  # @test1
        i32.const       0
        i32.load8_s     data
        end_function
test2:                                  # @test2
        local.get       0
        i32.const       data
        i32.add 
        i32.load8_s     0
        end_function
data:
        .asciz  "Hello world"
```

test2 should compile to this:
```
        local.get       0
        i32.load8_s     data
        end_function
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE1z2yAQ_TXosmMPBluyDjo4TTK9dHpIZ3rMIEASKRYeFiVNfn1Xst182U3DAJqnhcd7sFAH81h1Ke2QyQ0T11TbYOrg0zzEltATNXX3A4urq3DH-CXjm0Of80OdoO5UBKOSYqsLtroEJqkJ8dV6H-AhRG8IMXnxkmKakyymBRNr1ydw5jcTJbDiMAwg2jTE_kjMifmZo7g8SSb-k2yMn6R7bWzffwnbnfOub-HBpQ4oOruBWVKxtQkeFG6lgNl3pP_QunuL5H3dOJ9stGS8HDf3FPnevCRtHxUmJLAl3084-NkXJ8Vchx7TAfP3YR-UWd_ihCf3r0bY3tw2Q6-TC_2zLPFZWeI1qw9a-fm4PWdlvVT9XtY4QhkD_7bDP_IyER-3_zhsrlC7JziRoedTYPII2IXBG9BTPlhIAVLn8Nz5fmIzPntGf1fKbLXIcynWZUHAVNKUslRZcsnb6ufm5tt4kJsY1SPJCL-G3ZScqjcQUmfp0j72aus0KK0tosXx0hhaRRQJBiSLnYXQNEjiQwOjTHoSMIVosyH6t48H3Y6hppPdEvD-_viZ7WK4szoRdIjDuMr1qiiKRdZVNS-1WGplG1vLlShqWRIwC1EsdcObZeZVbT1W-5clc5XgQvBykXO-oja3ebFQKrdS1WUuVpry0W6V8_Nx4fEZy2I1aaiHFinoHSZ8DipE1_bWHvnVkLoQK8OxDiFhNumtJrF_AA76aik">