| Issue |
179489
|
| Summary |
[X86] Incorrect handling for truncated masked store
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
JaydeepChauhan14
|
**testcase**
```
define void @foo(<8 x i16> %arg, ptr addrspace(1) %add.ptr, i64 %dim0) {
entry:
%i3 = shufflevector <8 x i16> %arg, <8 x i16> <i16 poison, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257>, <8 x i32> <i32 0, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
%i4 = lshr <8 x i16> %i3, splat (i16 8)
%i5 = trunc <8 x i16> %i4 to <8 x i8>
call void @llvm.masked.store.v8i8.p1(<8 x i8> %i5, ptr addrspace(1) %add.ptr, <8 x i1> <i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>)
ret void
}
```
**Assembly with Bug**
```
vpextrw $0, %xmm0, %eax
shrl $8, %eax
movw %ax, (%rdi)
retq
```
**Correct assembly**
```
vbroadcastss .LCPI0_1(%rip), %xmm1 # xmm1 = [257,257,257,257,257,257,257,257]
vmovsh %xmm0, %xmm1, %xmm0 # xmm0 = xmm0[0],xmm1[1,2,3,4,5,6,7]
vpsrlw $8, %xmm0, %xmm0
movb $1, %al
kmovd %eax, %k1
vpmovwb %xmm0, (%rdi) {%k1}
```
- In Bug case we extract 16 bit from xmm0[0], shift right by 8 (bit 0-7 valid, 8-16 zero) and write 16 bits at ptr.
In correct case shift all elements of xmm0 by 8 bits to right, and then writes just a 8-bit like intended in IR.
**Reference PR** - https://github.com/llvm/llvm-project/pull/169827
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs