From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DB963385840E; Mon, 15 May 2023 18:44:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB963385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684176259; bh=xqj6qOhSLM1+7ZfHy7UA9qKGypqxwnM8qq5JJIInzfs=; h=From:To:Subject:Date:From; b=iXUEwjnJG/afQEveHnVyUPeYHDFxuXVZoqGZBjvwmtN6YNsjfK98Q4CkbxHxP8ixG E1Pc+XruI7COjuQPMaySokstTGgWk+kSRq+O/Bhch+Gf21EUMuHxJk0MPhOEH4ZJ94 7JP6SdUiEefyQKiatZf0jz3aw9V1plPXysleP8rA= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/109866] New: Sometimes using sub/test instead just test Date: Mon, 15 May 2023 18:44:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia 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 keywords 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109866 Bug ID: 109866 Summary: Sometimes using sub/test instead just test Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int g(void); int h(void); int t(void); int f(int a, int b) { int c =3D a - b; if(c =3D=3D 0) return g(); if (c > 0) return h(); return t(); } ``` This is reduced from bzip2 in spec 2006, though I am not so sure any more. On x86_64 GCC produces: ``` subl %esi, %edi testl %edi, %edi je .L5 jle .L3 jmp h() .L3: jmp t() .L5: jmp g() ``` But GCC should produce (likes clang/LLVM does): ``` cmpl %esi, %edi je .L5 jle .L3 jmp h() .L3: jmp t() .L5: jmp g() ``` Note a similar thing happens with aarch64 target too.=