llvm-project
llvm-project copied to clipboard
(sext (vzext x)) -> (vsext x) in sign_extend_inreg lowering incorrectly optimize the case when input type is a vector of i1
| Bugzilla Link | 18054 |
| Resolution | FIXED |
| Resolved on | Aug 13, 2014 22:59 |
| Version | trunk |
| OS | Linux |
| Attachments | test case |
Extended Description
During lowering of sign_extend_inreg, (sext (vzext x)) is optimized to (vsext x), however, it doesn't check the in-register type as that optimization is only valid when in-register type is a vector of i8, i16, or i32. E.g. if the in-register type is a vector of i1, (vsext x) cannot extend sign-bit.
A test case is attached. Run 'llc -mcpu=penryn < ss.ll' (with SSE only), it produces the following code
foo: # @foo .cfi_startproc
BB#0:
movdqa %xmm0, %xmm1
pshufb .LCPI0_0(%rip), %xmm1
pslld $31, %xmm1
psrad $31, %xmm1
movdqa %xmm0, %xmm2
pshufb .LCPI0_1(%rip), %xmm2
pslld $31, %xmm2
psrad $31, %xmm2
pmovsxbd %xmm0, %xmm3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pshufb .LCPI0_2(%rip), %xmm0
pslld $31, %xmm0
psrad $31, %xmm0
movdqa %xmm3, (%rdi)
movdqa %xmm0, 48(%rdi)
movdqa %xmm2, 32(%rdi)
movdqa %xmm1, 16(%rdi)
ret
.Ltmp0: .size foo, .Ltmp0-foo .cfi_endproc
Note that pmovsxbd marked. It's incorrect as the value in xmm0 is still i1.
fixed in r195779.