From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7C9233835424; Mon, 7 Jun 2021 20:08:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C9233835424 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/100951] New: vec_duplicate leads to worse code Date: Mon, 07 Jun 2021 20:08:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2021 20:08:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100951 Bug ID: 100951 Summary: vec_duplicate 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" [(set (match_operand:INT_BROADCAST_MODE 0 "register_operand") (vec_duplicate:INT_BROADCAST_MODE (match_operand: 1 "nonimmediate_operand")))] "TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC" { ix86_expand_integer_vec_duplicate (operands); DONE;=20 }) to x86 backend, I got [hjl@gnu-cfl-2 gcc]$ cat /tmp/x.c=20 typedef short __attribute__((__vector_size__ (8 * sizeof (short)))) V; V v, w; void foo (void) { w =3D __builtin_shuffle (v !=3D 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]$=20 since middld-end leaves us with an unfolded constant CTOR.=