From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8E30E3858C33; Tue, 1 Nov 2022 23:39:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E30E3858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667345974; bh=QKE53BXYX4Zi8OG0Ynau+UmLxB9p7NQ101uwUc80Ebo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WA1LyD5qy4cZ2yPgOSIQ/pAj4GmTX/GqKWlD2Z4VzHQKt6Me7CIyDDPMBa+5MD7sg o0F8cQqMUdjTsdbuRPnyGsde/GgKiOm2CUFYfubFkPbDZA/PmPDj5EoG/19j3z595c cPqjQOIcjM1wNSUBsQ3lmnr4MgtyTRJ+H/iLPFJE= From: "vineetg at rivosinc dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/106602] riscv: suboptimal codegen for zero_extendsidi2_shifted w/o bitmanip Date: Tue, 01 Nov 2022 23:39:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: vineetg at rivosinc dot com 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106602 --- Comment #10 from Vineet Gupta --- At expand time, RV backend was NOT creating REQ_EQUAL note for 1 << 38 (insn 8 7 9 2 (set (reg:DI 79) (ashift:DI (reg:DI 78) (const_int 38 [0x26]))) "../../../shifter.c":10:40 -1 However cse1 adds it anyways, so that was a false alarm. (insn 8 7 9 2 (set (reg:DI 79) (ashift:DI (reg:DI 78) (const_int 38 [0x26]))) "../../../../shifter.c":10:40 159 {ashl= di3} (expr_list:REG_EQUAL (const_int 274877906944 [0x4000000000]) So when entering combine, we have following (insn 6 3 7 2 (set (reg:DI 76) (ashift:DI (reg/v:DI 74 [ a ]) (const_int 6 [0x6]))) (insn 7 6 8 2 (set (reg:DI 78) (const_int 1 [0x1])) (insn 8 7 9 2 (set (reg:DI 79) (ashift:DI (reg:DI 78) (const_int 38 [0x26]))) (expr_list:REG_EQUAL (const_int 274877906944 [0x4000000000]) (insn 9 8 10 2 (set (reg:DI 77) (plus:DI (reg:DI 79) (const_int -64 [0xffffffffffffffc0]))) (expr_list:REG_EQUAL (const_int 274877906880 [0x3fffffffc0]) (insn 10 9 15 2 (set (reg:DI 75) (and:DI (reg:DI 76) (reg:DI 77))) Obviously the regular code flow can't merge/match 5. The trailing note processing in combine replaces the pattern with available= set REG_EQUAL but it only handles two instructions at a time. This issue needs = it to handle three: insn 9, 10, 6 Perhaps we need to do the REQ_EQUAL note handling not seperately in the end, but as part of each of 2 insn combine / 3 insn combine / 4 insn combine (af= ter the regular try_combine() fails for each of them ?=