<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54896>54896</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AMDGPU] GPU Load and Store vectorizer creates faulty code with opaque pointers
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AMDGPU
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jdoerfert
</td>
</tr>
</table>
<pre>
The issue arises only if the geps use opaque pointers, here is a working version and a broken one, both run with: `--load-store-vectorizer -mtriple=amdgcn-amd-amdhsa`
(https://godbolt.org/z/74oqP3Ks5)
```
%S = type { i64, i64 }
@S = external global %S
define i64 @order() {
%idx1 = getelementptr inbounds %S, %S* @S, i32 0, i32 1
%l1 = load i64, i64* %idx1, align 8
%idx0 = getelementptr inbounds %S, %S* @S, i32 0, i32 0
%l0 = load i64, i64* %idx0, align 8
%add = add i64 %l0, %l1
ret i64 %add
}
```
```
%S = type { i64, i64 }
@S = external global %S
define i64 @order() {
%idx1 = getelementptr inbounds %S, ptr @S, i32 0, i32 1
%l1 = load i64, i64* %idx1, align 8
%idx0 = getelementptr inbounds %S, ptr @S, i32 0, i32 0
%l0 = load i64, i64* %idx0, align 8
%add = add i64 %l0, %l1
ret i64 %add
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVUtvnDAQ_jVwGbEy5rHhwGHTVXpoK0VK-wPMegAnXkxsk2Tz6zuG3TxWSi-9pFIRMIzn9c0wmmmMPNQ_ewTl3IQgrHLowAz6AKoFT4IORweTQzCjuCeV0ajBo3UR_wI92mAJAh6NvVNDBw8kUWYAMUg6bay5w4HcYdBujO_BTgM8Kt9H2QaikiWJNkImzhuLyQPuiKpntJDsvVWjxijbir3sdkNCJDy9E2QGEdtGbBPxi9770ZGziF_R3RnZGO1XxnbEPdOzzs39dfbNFRGvjkbLu2THe2YBIl7cAIUDfxgRovUlqDIPsIkQu33Ry9mih09UhkFo6LRpiAQHL0pHKrFVAy4ucmasREuYCUoIcFKaYyv5lM5uO_SocY-DH70FNTRmGqRbvBOahW5mGDO6jAM7faTvXOrFYSjwm1xm4yVeOBFadQNcnGNhf42FwSe43teD_bke7KN6CClny0DnXxl8HQug39Tcoj_JSfWlF069c9Zy_3YfhsPP0IMf4vjffx_2XyzrTFZZJWKvvMY6Ki43P7Zfr39FxRaIwPcAMYzwmzCX4c1c3lkUnjZEKybtD7AzEudxfr4d4snq-mw2k9rUrHZmT4zWDyeSjNbcUgRi5yVEm-WqyC-qMu7rIsOsrdJUpHnVrCtkbVPwSrS8yCteZlmsRYPahQwizhuxo3UjKeIxHc4po1jVnHHO8jRL1zxn5YqJol3LvChkiZKxnPoH90LpVYATdkds6xlZM3WOhFo5716Fwjn6RzjXLfgXk--NrW-lQdui9fGcRj3n8Bukp_Cu">