From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3D214398B86C; Fri, 5 Mar 2021 14:30:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D214398B86C From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/99411] New: s311 benchmark of TSVC is vectorized by clang better than by gcc Date: Fri, 05 Mar 2021 14:30:55 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org 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 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: Fri, 05 Mar 2021 14:30:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99411 Bug ID: 99411 Summary: s311 benchmark of TSVC is vectorized by clang better than by gcc Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- typedef float real_t; #define iterations 100000 #define LEN_1D 32000 #define LEN_2D 256 real_t a[LEN_1D]; int main() { // reductions // sum reduction real_t sum; for (int nl =3D 0; nl < iterations*10; nl++) { sum =3D (real_t)0.; for (int i =3D 0; i < LEN_1D; i++) { sum +=3D a[i]; } } return sum > 4; } We produce with -O2 -march=3Dznver2 .L2: movl $a, %eax vxorps %xmm0, %xmm0, %xmm0 .p2align 4 .p2align 3 .L3: vaddps (%rax), %ymm0, %ymm0 addq $32, %rax cmpq $a+128000, %rax jne .L3 vextractf128 $0x1, %ymm0, %xmm1 decl %edx vaddps %xmm0, %xmm1, %xmm1 vmovhlps %xmm1, %xmm1, %xmm0 vaddps %xmm1, %xmm0, %xmm0 vshufps $85, %xmm0, %xmm0, %xmm1 vaddps %xmm0, %xmm1, %xmm0 jne .L2 xorl %eax, %eax vcomiss .LC0(%rip), %xmm0 seta %al vzeroupper ret .cfi_endproc clang does: main: # @main .cfi_startproc # %bb.0: xorl %eax, %eax .p2align 4, 0x90 .LBB0_1: # =3D>This Loop Header: Depth=3D1 # Child Loop BB0_2 Depth 2 vxorps %xmm0, %xmm0, %xmm0 movq $-128000, %rcx # imm =3D 0xFFFE0C00 vxorps %xmm1, %xmm1, %xmm1 vxorps %xmm2, %xmm2, %xmm2 vxorps %xmm3, %xmm3, %xmm3 .p2align 4, 0x90 .LBB0_2: # Parent Loop BB0_1 Depth=3D1 # =3D> This Inner Loop Header: Dep= th=3D2 vaddps a+128000(%rcx), %ymm0, %ymm0 vaddps a+128032(%rcx), %ymm1, %ymm1 vaddps a+128064(%rcx), %ymm2, %ymm2 vaddps a+128096(%rcx), %ymm3, %ymm3 subq $-128, %rcx jne .LBB0_2 # %bb.3: # in Loop: Header=3DBB0_1 Depth= =3D1 incl %eax cmpl $1000000, %eax # imm =3D 0xF4240 jne .LBB0_1 # %bb.4: vaddps %ymm0, %ymm1, %ymm0 xorl %eax, %eax vaddps %ymm0, %ymm2, %ymm0 vaddps %ymm0, %ymm3, %ymm0 vextractf128 $1, %ymm0, %xmm1 vaddps %xmm1, %xmm0, %xmm0 vpermilpd $1, %xmm0, %xmm1 # xmm1 =3D xmm0[1,0] vaddps %xmm1, %xmm0, %xmm0 vmovshdup %xmm0, %xmm1 # xmm1 =3D xmm0[1,1,3,3] vaddss %xmm1, %xmm0, %xmm0 vucomiss .LCPI0_0(%rip), %xmm0 seta %al vzeroupper retq On zen3 hardware gcc version runs 2.4s, while clang's 0.8s=