Issue |
97720
|
Summary |
[X86] Failure to match PMADDUBSW horizontal adds
|
Labels |
backend:X86
|
Assignees |
|
Reporter |
RKSimon
|
We correctly match this as PMADDWD:
```c
}
__v4si _mm_mul_hadd_epi16(__v8hi x, __v8hi y) {
__v4si xl = __builtin_convertvector(__builtin_shufflevector(x,x,0,2,4,6), __v4si);
__v4si yl = __builtin_convertvector(__builtin_shufflevector(y,y,0,2,4,6), __v4si);
__v4si xh = __builtin_convertvector(__builtin_shufflevector(x,x,1,3,5,7), __v4si);
__v4si yh = __builtin_convertvector(__builtin_shufflevector(y,y,1,3,5,7), __v4si);
return (xl * yl) + (xh*yh);
}
```
```asm
_mm_mul_hadd_epi16(short vector[8], short vector[8]): # @_mm_mul_hadd_epi16(short vector[8], short vector[8])
vpmaddwd %xmm0, %xmm1, %xmm0
retq
```
But fail to do the same for PMADDUBSW:
```c
__v8hi _mm_mul_hadd_epi8(__v16qu x, __v16qi y) {
__v8hu xl = __builtin_convertvector(__builtin_shufflevector(x,x,0,2,4,6,8,10,12,14), __v8hu);
__v8hi yl = __builtin_convertvector(__builtin_shufflevector(y,y,0,2,4,6,8,10,12,14), __v8hi);
__v8hu xh = __builtin_convertvector(__builtin_shufflevector(x,x,1,3,5,7,9,11,13,15), __v8hu);
__v8hu yh = __builtin_convertvector(__builtin_shufflevector(y,y,1,3,5,7,9,11,13,15), __v8hi);
return (xl * yl) + (xh*yh);
}
```
```asm
_mm_mul_hadd_epi8(unsigned char vector[16], char vector[16]): # @_mm_mul_hadd_epi8(unsigned char vector[16], char vector[16])
vpmovwb %xmm1, %xmm3
vpshufb .LCPI0_1(%rip), %xmm1, %xmm1 # xmm1 = xmm1[1,3,5,7,9,11,13,15,u,u,u,u,u,u,u,u]
vpandd .LCPI0_2(%rip){1to4}, %xmm0, %xmm2
vpsrlw $8, %xmm0, %xmm0
vpmovsxbw %xmm3, %xmm3
vpmovsxbw %xmm1, %xmm1
vpmullw %xmm2, %xmm3, %xmm2
vpmullw %xmm0, %xmm1, %xmm0
vpaddw %xmm0, %xmm2, %xmm0
retq
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs