From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4A10D3858C3A; Mon, 26 Jul 2021 11:14:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A10D3858C3A From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/78103] Failure to optimize with __builtin_clzl Date: Mon, 26 Jul 2021 11:14:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 6.2.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW 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: cc Message-ID: In-Reply-To: References: 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, 26 Jul 2021 11:14:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D78103 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |segher at gcc dot gnu.org --- Comment #10 from Jakub Jelinek --- Unfortunately, it doesn't work for the #c0 testcase, after the combiner splitter kicks in, the combiner doesn't even try that 4 insn combination.=20 Haven't debugged it, but it looks like if LOG_LINKS isn't added between the= 2 insns that replaced the 3 insns. There is the successful: Trying 9, 10 -> 12: 9: {flags:CCZ=3Dcmp(r85:DI,0);r86:DI=3D0x3f-clz(r85:DI);} REG_DEAD r85:DI REG_UNUSED flags:CCZ 10: {r86:DI=3Dr86:DI^0x3f;clobber flags:CC;} REG_UNUSED flags:CC 12: r87:DI=3Dsign_extend(r86:DI#0) REG_DEAD r86:DI Failed to match this instruction: (set (reg:DI 87 [ _1 ]) (xor:DI (sign_extend:DI (minus:SI (const_int 63 [0x3f]) (subreg:SI (clz:DI (reg/v:DI 85 [ x ])) 0))) (const_int 63 [0x3f]))) Splitting with gen_split_440 (i386.md:14804) Successfully matched this instruction: (set (reg:DI 93) (minus:DI (const_int 63 [0x3f]) (clz:DI (reg/v:DI 85 [ x ])))) Successfully matched this instruction: (set (reg:DI 87 [ _1 ]) (zero_extend:DI (xor:SI (subreg:SI (reg:DI 93) 0) (const_int 63 [0x3f])))) allowing combination of insns 9, 10 and 12 original costs 8 + 4 + 4 =3D 16 replacement costs 8 + 5 =3D 13 deferring deletion of insn with uid =3D 9. modifying insn i2 10: {r93:DI=3D0x3f-clz(r85:DI);clobber flags:CC;} REG_UNUSED flags:CC REG_DEAD r85:DI deferring rescan insn with uid =3D 10. modifying insn i3 12: {r87:DI=3Dzero_extend(r93:DI#0^0x3f);clobber flags= :CC;} REG_UNUSED flags:CC deferring rescan insn with uid =3D 12. and I was hoping that the combiner would soon try 10, 12, 13 -> 14 combinat= ion where 10 and 12 are the above 2 new insns, 13 is r88:DI=3D0x40 and 14 is {r85:DI=3Dr88:DI-r87:DI;clobber flags:CC;}. But all it tries is 12 -> 14, 13 -> 14, 13, 12 -> 14 and all those fail. Segher, any ideas?=