From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C0F593858430; Tue, 12 Oct 2021 13:41:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0F593858430 From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102705] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) Date: Tue, 12 Oct 2021 13:41:56 +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: theodort at inf dot ethz.ch 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: Tue, 12 Oct 2021 13:41:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102705 Bug ID: 102705 Summary: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: theodort at inf dot ethz.ch Target Milestone: --- cat test.c void foo(void); static int b; static char c; static short a(short d, short e) { return e =3D=3D 0 || d && e =3D=3D 1 ? 0= : d % e; } int main() { b =3D c =3D b >=3D 2 ? 0 : 1 >> b; short f =3D a(0 >=3D 0 ^ c, 5); if (f =3D=3D c) foo(); a(0, 9); } 11.2.0 at -O3 can eliminate the call to foo but trunk at -O3 cannot: gcc-11.2.0 test.c -S -O3 -o /dev/stdout main: .LFB1: .cfi_startproc movl b(%rip), %ecx movl $1, %eax sarl %cl, %eax movl %eax, %edx xorl %eax, %eax cmpl $2, %ecx cmovl %edx, %eax movsbl %al, %eax movl %eax, b(%rip) xorl %eax, %eax ret .cfi_endproc gcc-trunk test.c -S -O3 -o /dev/stdout main: .LFB1: .cfi_startproc movl b(%rip), %ecx cmpl $1, %ecx jle .L2 xorl %ecx, %ecx movl %ecx, b(%rip) .L5: xorl %eax, %eax ret .L2: movl $1, %eax sarl %cl, %eax movl %eax, %edx movl %eax, b(%rip) xorl $1, %edx movsbw %dl, %dx cmpw %ax, %dx jne .L5 pushq %rax .cfi_def_cfa_offset 16 call foo xorl %eax, %eax popq %rdx .cfi_def_cfa_offset 8 ret .cfi_endproc gcc-trunk -v=20=20=20 Using built-in specs. Target: x86_64-pc-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.0.0 20211012 (experimental) (GCC) It started with https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3D145bc41dae7c7bfa093d61e= 77346f98e6a595a0e=