| Issue |
235677
|
| Summary |
[SLP][X86] Big-endian 32-bit store vectorized to pshufb instead of bswap/movbe
|
| Labels |
backend:X86,
llvm:SLPVectorizer,
regression:22,
regression:24
|
| Assignees |
|
| Reporter |
chfast
|
```c
void put_be32(unsigned char *p, unsigned x) {
p[0] = x >> 24;
p[1] = x >> 16;
p[2] = x >> 8;
p[3] = x;
}
```
https://godbolt.org/z/dc9T1Mbjx
`-O2 -march=x86-64-v2`, clang 23 vs trunk:
```asm
bswap esi
mov dword ptr [rdi], esi
```
```asm
movd xmm0, esi
pshufb xmm0, xmmword ptr [rip + .LCPI0_0]
movd dword ptr [rdi], xmm0
```
This started with 67005b724c91 (#224919): SLP now turns the four byte stores into a reverse shuffle of the value bitcast to `<4 x i8>`. With `-march=x86-64-v3` it has been vectorized since clang 22 (`vpbroadcastd` + `vpshufb`); clang 21 emitted a single `movbe dword ptr [rdi], esi`.
Found in evmone's SHA-256, which writes the hash words this way.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs