From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C2C273857C6B; Fri, 15 Oct 2021 00:16:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2C273857C6B From: "law at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102756] New: [12 Regression] Vectorizer change creates poor code for c-c++-common/torture/vector-compare-2.c Date: Fri, 15 Oct 2021 00:16:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: law 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, 15 Oct 2021 00:16:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102756 Bug ID: 102756 Summary: [12 Regression] Vectorizer change creates poor code for c-c++-common/torture/vector-compare-2.c Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: law at gcc dot gnu.org Target Milestone: --- The visium-elf port is a bit broken in that any code which calls abort will fail to link. This has turned out to be useful in that it has pointed out cases where the quality of our code generation has suffered. The change to turn on the vectorizer by default at -O2 is yet another examp= le. c-c++-common/torture/vector-compare-2.c before the vectorizer change compil= ed down to this code at -O2: .file "j.c" .text .align 4 .p2align 8 .global foo .type foo, @function foo: moviu r9,65535 movil r9,65533 write.l (r1),r9 write.l 1(r1),r9 write.l 2(r1),r9 bra tr,r21,r0 ;return write.l 3(r1),r9 .size foo, .-foo .section .text.startup,"ax",@progbits .align 4 .p2align 8 .global main .type main, @function main: bra tr,r21,r0 ;return moviq r1,0 ;movsi r J .size main, .-main .ident "GCC: (GNU) 12.0.0 20211008 (experimental)" Of particular note "main" does _not_ call abort. The optimizers have figur= ed everything out and realized that it should never abort. After enabling the vectorizer at -O2 we get: .file "j.c" .text .align 4 .p2align 8 .global foo .type foo, @function foo: moviu r9,65535 movil r9,65533 write.l (r1),r9 write.l 1(r1),r9 write.l 2(r1),r9 bra tr,r21,r0 ;return write.l 3(r1),r9 .size foo, .-foo .section .text.startup,"ax",@progbits .align 4 .p2align 8 .global main .type main, @function main: subi sp,36 moviq r10,23 ;movsi r J write.l (sp),fp move.l fp,sp ;stack_save add.l r8,fp,r10 lsr.l r8,r8,4 asl.l r8,r8,4 moviu r9,65535 write.l 1(sp),r21 movil r9,65533 write.l (r8),r9 write.l 1(r8),r9 write.l 2(r8),r9 write.l 3(r8),r9 move.l r10,r8 moviq r8,16 ;movsi r J add.l r7,r10,r8 .L5: read.l r8,(r10) cmp.l r8,r9 brr ne,.L8 addi r10,4 cmp.l r10,r7 brr ne,.L5 moviq r1,0 ;movsi r J read.l fp,(sp) read.l r21,1(sp) bra tr,r21,r0 ;return addi sp,36 ;stack pop .L8: moviu r10,%u abort movil r10,%l abort bra tr,r10,r21 nop ;call .size main, .-main .ident "GCC: (GNU) 12.0.0 20211008 (experimental)" Note how there's a call to abort starting at the label .L8. And more gener= ally the code in "main" is considerably larger and more complex. This is a code quality regression.=