Inefficient x86 vector code generation for load v4i8 to v16i8
| Bugzilla Link | 16026 |
| Resolution | FIXED |
| Resolved on | Dec 13, 2014 11:38 |
| Version | trunk |
| OS | Linux |
| CC | @RKSimon |
Fixed in ToT at somepoint in the past 18 months - both with/without -x86-experimental-vector-shuffle-lowering
.globl _v4i8
.align 4, 0x90
_v4i8: ## @v4i8 .cfi_startproc
BB#0:
vmovd (%rdi), %xmm0
retq
.cfi_endproc
proposed patch This patch fixes it.
LLVM should compile the following IR
define <16 x i8> @v4i8(<4 x i8>* %p) { %v1 = load <4 x i8>* %p %v2 = shufflevector <4 x i8> %v1, <4 x i8> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 4, i32 5, i32 6, i32 7, i32 4, i32 5, i32 6, i32 7> ret <16 x i8> %v2 }
into a single movd as the high parts are all undefined. But, ToT generates the following code
.section .rodata.cst16,"aM",@progbits,16
.align 16
.LCPI1_0: .byte 128 # 0x80 .byte 1 # 0x1 .byte 2 # 0x2 .byte 3 # 0x3 .byte 4 # 0x4 .byte 5 # 0x5 .byte 6 # 0x6 .byte 7 # 0x7 .byte 8 # 0x8 .byte 9 # 0x9 .byte 10 # 0xa .byte 11 # 0xb .byte 12 # 0xc .byte 13 # 0xd .byte 14 # 0xe .byte 15 # 0xf .LCPI1_1: .byte 0 # 0x0 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .byte 128 # 0x80 .text .globl v4i8 .align 16, 0x90 .type v4i8,@function v4i8: # @v4i8 .cfi_startproc
BB#0:
vmovd (%rdi), %xmm1
vpshufb .LCPI1_0(%rip), %xmm1, %xmm0
vpmovzxbd %xmm1, %xmm1
vpshufb .LCPI1_1(%rip), %xmm1, %xmm1
vpor %xmm1, %xmm0, %xmm0
ret
.Ltmp1: .size v4i8, .Ltmp1-v4i8 .cfi_endproc