<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113262>113262</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AVX-512] Only `qword ptr` and `zmmword ptr` dereferences are folded into `vpand`?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Validark
</td>
</tr>
</table>
<pre>
This code: ([Godbolt link](https://zig.godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYgAzKVpMGoAF55gpJfWQE8Ayo3QBhVLQCuLBhICspJwAyeAyYAHKeAEaYxCAATBqkAA6oCoT2DK4eXr5JKWkCQSHhLFEx8VaYNnYCQgRMxASZnt5cftaYtum19QSFYZHRcQkKdQ1N2a1Wo73B/SWD8QCUVqjuxMjsHGgMIwDUI%2Bi7AKR6ACK7AAJ4LMkNEEexsQcPsYsnAEJHGgCCX9%2BYqluBF2VAYINQqAgTBAlwAah0iMQIAA2aS7dwADmWuwiMIAVBd4bYSBAuKR0VjFnCESTUeTMVSjgB2T4/Xbs3bETAENZgpjHWLI/YEdAAOlSLDFXMSmCYBBRaIiorxbz0rN%2BTNOfz%2BAKBILBEXqUJhhJpSLpFOxuN2BKJiIgsXplOpxPNaIZxxZfw5nO5vN2/IeQoO4uuUswMrlCvJSpVH21mu1P11JGBoJxTFMxpd9otDJj%2BNNrog7udRdzpcZXrZHK5POIfIFwZFocloulsvlFtjqvVzK1Px1gNT%2BpxAE9MNny7TKwWbdOkRinYsqQvo5bPeqfXX/YHBcKxRLw5Gu4rlb2EwPfsnhw1R4a8FO7TPl3PbWbScjl6vn27l5vvVrP0GwDJsD1bY9O3XHt40HRNBxvPV00NAB3J8PzzLE3zXPRHUtH8MMrACa3ZHcQL3ZtDzD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3debcbJ2UGKbWe88%2B5LyWolVeaUCmkBcv3Qew8mSj3HpPaeYUODmT8cvJK%2BTobeNiCXSpK8%2BmZWWADVIDhJBAA%3D%3D%3D))
```zig
const std = @import("std");
export fn foo(a: @Vector(64, u8), b: *@Vector(1, u8)) @Vector(64, u8) {
return a & std.simd.repeat(64, b.*);
}
export fn bar(a: @Vector(64, u8), b: *@Vector(2, u8)) @Vector(64, u8) {
return a & std.simd.repeat(64, b.*);
}
export fn baz(a: @Vector(64, u8), b: *@Vector(4, u8)) @Vector(64, u8) {
return a & std.simd.repeat(64, b.*);
}
export fn bye(a: @Vector(64, u8), b: *@Vector(8, u8)) @Vector(64, u8) {
return a & std.simd.repeat(64, b.*);
}
export fn bai(a: @Vector(64, u8), b: *@Vector(16, u8)) @Vector(64, u8) {
return a & std.simd.repeat(64, b.*);
}
export fn baw(a: @Vector(64, u8), b: *@Vector(32, u8)) @Vector(64, u8) {
return a & std.simd.repeat(64, b.*);
}
export fn baq(a: @Vector(64, u8), b: *@Vector(64, u8)) @Vector(64, u8) {
return a & std.simd.repeat(64, b.*);
}
```
Produces this for Zen 5 targets:
```asm
foo:
vpbroadcastb zmm1, byte ptr [rdi]
vpandq zmm0, zmm1, zmm0
ret
bar:
vpbroadcastw zmm1, word ptr [rdi]
vpandq zmm0, zmm1, zmm0
ret
baz:
vbroadcastss zmm1, dword ptr [rdi]
vandps zmm0, zmm1, zmm0
ret
bye:
vandpd zmm0, zmm0, qword ptr [rdi]{1to8}
ret
bai:
vbroadcasti32x4 zmm1, xmmword ptr [rdi]
vpandq zmm0, zmm1, zmm0
ret
baw:
vbroadcasti64x4 zmm1, ymmword ptr [rdi]
vpandq zmm0, zmm1, zmm0
ret
baq:
vandps zmm0, zmm0, zmmword ptr [rdi]
ret
```
Why is it that only the `qword ptr` and `zmmword ptr` dereferences are folded into the `vpand`? Can't most or all of these be folded into the `vpand`?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMmFmzsrjWg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