[X86] suboptimal mixed vecinit codegen
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
found from https://github.com/gcc-mirror/gcc/commit/f0bd50e831792692ffcedf288b312167a9339260
https://godbolt.org/z/81WcaoTMq
```c
typedef int v4si __attribute__ ((__vector_size__ (16)));
v4si f0a00(int a) { return (v4si){0,a,0,0}; }
v4si f00a0(int a) { return (v4si){0,0,a,0}; }
v4si faa00(int a) { return (v4si){a,a,0,0}; }
v4si fa0a0(int a) { return (v4si){a,0,a,0}; }
```
gcc:
```asm
"f0a00":
vmovd xmm0, edi
vpslldq xmm0, xmm0, 4
ret
"f00a0":
vmovd xmm0, edi
vpslldq xmm0, xmm0, 8
ret
"faa00":
vmovd xmm0, edi
vshufps xmm0, xmm0, xmm0, 80
ret
"fa0a0":
vmovd xmm0, edi
vshufps xmm0, xmm0, xmm0, 68
ret
```
clang:
```asm
.LCPI0_0:
.byte 128
.byte 128
.byte 128
.byte 128
.byte 0
.byte 1
.byte 2
.byte 3
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
f0a00:
vmovd xmm0, edi
vpshufb xmm0, xmm0, xmmword ptr [rip + .LCPI0_0]
ret
.LCPI1_0:
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 0
.byte 1
.byte 2
.byte 3
.byte 128
.byte 128
.byte 128
.byte 128
f00a0:
vmovd xmm0, edi
vpshufb xmm0, xmm0, xmmword ptr [rip + .LCPI1_0]
ret
.LCPI2_0:
.byte 0
.byte 1
.byte 2
.byte 3
.byte 0
.byte 1
.byte 2
.byte 3
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
.byte 128
faa00:
vmovd xmm0, edi
vpshufb xmm0, xmm0, xmmword ptr [rip + .LCPI2_0]
ret
.LCPI3_0:
.byte 0
.byte 1
.byte 2
.byte 3
.byte 128
.byte 128
.byte 128
.byte 128
.byte 0
.byte 1
.byte 2
.byte 3
.byte 128
.byte 128
.byte 128
.byte 128
fa0a0:
vmovd xmm0, edi
vpshufb xmm0, xmm0, xmmword ptr [rip + .LCPI3_0]
ret
```
Contributor guide
Research direction
Start with the C reproducer and the Godbolt comparison linked in the issue, then inspect how LLVM lowers these mixed vector initializers for x86. Compare the generated assembly for all four functions with the GCC and Clang outputs; done means the suboptimal code generation is addressed and covered by an appropriate compiler test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100