Take the following code: #define vector __attribute__((__vector_size__(16))) vector char bar (char x) { return (vector char){ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x }; } ---- We currently produce crappy code: pushl %edx movzbw 8(%esp), %ax movl %eax, %edx sall $8, %edx orl %eax, %edx movzwl %dx, %edx movl %edx, %eax sall $16, %eax orl %edx, %eax movl %eax, (%esp) movd (%esp), %xmm1 pshufd $0, %xmm1, %xmm0 popl %eax ret ---- The issue looks like we are expanding this crappy: insn 12 11 13 (set (reg:V16QI 62) (const_vector:V16QI [ (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) (const_int 0 [0x0]) ])) -1 (nil) (nil))
(insn 13 12 14 (parallel [ (set (reg:HI 63) (zero_extend:HI (reg/v:QI 59 [ x ]))) (clobber (reg:CC 17 flags)) ]) -1 (nil) (nil)) (insn 14 13 15 (parallel [ (set (reg:HI 64) (ashift:HI (reg:HI 63) (const_int 8 [0x8]))) (clobber (reg:CC 17 flags)) ]) -1 (nil) (nil)) (insn 16 15 17 (set (reg:SI 66) (zero_extend:SI (reg:HI 64))) -1 (nil) (nil)) (insn 17 16 18 (parallel [ (set (reg:SI 67) (ashift:SI (reg:SI 66) (const_int 16 [0x10]))) (clobber (reg:CC 17 flags)) ]) -1 (nil) (nil)) (insn 18 17 19 (parallel [ (set (reg:SI 67) (ior:SI (reg:SI 67) (reg:SI 66))) (clobber (reg:CC 17 flags)) ]) -1 (nil) (nil)) (insn 19 18 20 (set (reg:V4SI 68) (vec_duplicate:V4SI (reg:SI 67))) -1 (nil) (nil)) (insn 20 19 21 (set (reg:V8HI 65) (subreg:V8HI (reg:V4SI 68) 0)) -1 (nil) (nil)) (insn 21 20 22 (set (reg:V16QI 62) (subreg:V16QI (reg:V8HI 65) 0)) -1 (nil) (nil)) -- Summary: (vector char){x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x} code gen is not that good Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: missed-optimization, ssemmx Severity: minor Priority: P2 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org GCC target triplet: i786-pc-darwin7.9 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24076