From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F287E3858C74; Thu, 3 Nov 2022 04:15:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F287E3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667448906; bh=J73AzdlxA3bt/WMYxVtE3tNlpS4zR6EIKAu0W3OgEuE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nUGaHwJTHv9WAeCEVtwqlfc9SpZpCKU8ORYUHSBCpba0Dbrz/YNdVB6mEfph7BI+4 0HSbb1oXalfn8VEE/V58XenXuq/NfcypWLGMHfjJJ5IXTai0ywRUqRkQ7RaldHwDNA q/UqkY9uNJJ8QH0rKcKNEdUpGSXuqXJA6pyaeqNA= 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: Thu, 03 Nov 2022 04:15:05 +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: enhancement 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 #21 from Vineet Gupta --- I've been experimenting with=20 (define_predicate "consecutive_bits_operand" (match_code "const_int") { unsigned HOST_WIDE_INT val =3D UINTVAL (op); if (exact_log2 ((val >> ctz_hwi (val)) + 1) < 0) return false; return true; }) (define_split [(set (match_operand:DI 0 "register_operand") (and:DI (match_operand:DI 1 "register_operand") (match_operand:DI 2 "consecutive_bits_operand"))) (clobber (match_operand:DI 3 "register_operand"))] "TARGET_64BIT" [(set (match_dup 3) (lshiftrt:DI (match_dup 1) (match_dup 4))) (set (match_dup 3) (ashift:DI (match_dup 3) (match_dup 5))) (set (match_dup 0) (lshiftrt:DI (match_dup 3) (match_dup 6)))] { unsigned HOST_WIDE_INT mask =3D UINTVAL (operands[2]); int r =3D ctz_hwi (mask); int l =3D clz_hwi (mask); operands[4] =3D GEN_INT (r); operands[5] =3D GEN_INT (r+l); operands[6] =3D GEN_INT (l); }) However=20 try_combine recog_for_combine recog_for_combine_1 recog( ) is failing and we get "Failed to recognize..." (gdb) call debug_rtx(x1) (set (reg:DI 75) (and:DI (reg:DI 76) (const_int 274877906880 [0x3fffffffc0]))) I can't step through recog() cpp code since gen* insert #line for md file a= nd gdb steps through unrelated md code. FWIW cc1 is being built with -g3 -O0=