[Bug middle-end/100951] New: vec_duplicate<mode> leads to worse code
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 7 20:08:24 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100951
Bug ID: 100951
Summary: vec_duplicate<mode> leads to worse code
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
CC: rguenther at suse dot de
Target Milestone: ---
After I added
;; Modes handled by broadcast patterns.
(define_mode_iterator INT_BROADCAST_MODE
[(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
(V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
(V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
(V8DI "TARGET_AVX512F") (V4DI "TARGET_64BIT") V2DI])
;; Broadcast from an integer. NB: Enable broadcast only if we can move
;; from GPR to SSE register directly. */
(define_expand "vec_duplicate<mode>"
[(set (match_operand:INT_BROADCAST_MODE 0 "register_operand")
(vec_duplicate:INT_BROADCAST_MODE
(match_operand:<ssescalarmode> 1 "nonimmediate_operand")))]
"TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
{
ix86_expand_integer_vec_duplicate (operands);
DONE;
})
to x86 backend, I got
[hjl@gnu-cfl-2 gcc]$ cat /tmp/x.c
typedef short __attribute__((__vector_size__ (8 * sizeof (short)))) V;
V v, w;
void
foo (void)
{
w = __builtin_shuffle (v != v, 0 < (V) {}, (V) {192} >> 5);
}
[hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -S /tmp/x.c
[hjl@gnu-cfl-2 gcc]$ cat x.s
.file "x.c"
.text
.globl v
.bss
.align 16
.type v, @object
.size v, 16
v:
.zero 16
.globl w
.align 16
.type w, @object
.size w, 16
w:
.zero 16
.text
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $0, %eax
movd %eax, %xmm0
punpcklwd %xmm0, %xmm0
pshufd $0, %xmm0, %xmm0
movaps %xmm0, w(%rip)
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.ident "GCC: (GNU) 12.0.0 20210607 (experimental)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-cfl-2 gcc]$
since middld-end leaves us with an unfolded constant CTOR.
More information about the Gcc-bugs
mailing list