[AVX-512] Replace static `vpermi2w` with `vpermi2b` on Intel
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
On many Intel targets, `vpermi2w` has higher latency than `vpermi2b`. Therefore, we should prefer to use `vpermi2b` where we can.
```llvm
define dso_local <64 x i8> @foo(<64 x i8> %0) local_unnamed_addr {
Entry:
%1 = shufflevector <64 x i8> %0, <64 x i8> poison, <64 x i32>
ret <64 x i8> %1
}
```
Compiles to:
```asm
.LCPI0_1:
.byte 0
.byte 4
.byte 8
.byte 12
.byte 16
.byte 20
.byte 24
.byte 28
.byte 1
.byte 5
.byte 9
.byte 13
.byte 17
.byte 21
.byte 25
.byte 29
.byte 2
.byte 6
.byte 10
.byte 14
.byte 18
.byte 22
.byte 26
.byte 30
.byte 3
.byte 7
.byte 11
.byte 15
.byte 19
.byte 23
.byte 27
.byte 31
foo:
vpmovsxbw zmm1, ymmword ptr [rip + .LCPI0_1]
vpermw zmm0, zmm1, zmm0
ret
```
Should be:
```asm
.LCPI0_0:
.byte 0
.byte 1
.byte 8
.byte 9
.byte 16
.byte 17
.byte 24
.byte 25
.byte 32
.byte 33
.byte 40
.byte 41
.byte 48
.byte 49
.byte 56
.byte 57
.byte 2
.byte 3
.byte 10
.byte 11
.byte 18
.byte 19
.byte 26
.byte 27
.byte 34
.byte 35
.byte 42
.byte 43
.byte 50
.byte 51
.byte 58
.byte 59
.byte 4
.byte 5
.byte 12
.byte 13
.byte 20
.byte 21
.byte 28
.byte 29
.byte 36
.byte 37
.byte 44
.byte 45
.byte 52
.byte 53
.byte 60
.byte 61
.byte 6
.byte 7
.byte 14
.byte 15
.byte 22
.byte 23
.byte 30
.byte 31
.byte 38
.byte 39
.byte 46
.byte 47
.byte 54
.byte 55
.byte 62
.byte 63
sh:
vmovdqa64 zmm1, zmmword ptr [rip + .LCPI0_0]
vpermb zmm0, zmm1, zmm0
ret
```
Contributor guide
Assessment
This issue has not been assessed yet.