From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4D4EE385840D; Wed, 24 Apr 2024 15:20:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D4EE385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713972043; bh=PSjU8BPqwpnamx/VaF1+iska+2S4OI9V8La8KLcwqo4=; h=From:To:Subject:Date:From; b=bFkKBWVJJeueZ+S4BGKegJNd33uH6YISVJY4C5H+TGOGOWQlpzdduJO8q8oQTMgD7 ZEkck8LFAZM+rDgwiKH+cwkEdRfK6twwLmqNwvwra2iwr/hIEfnNK74uI1HeXQ/TN5 F0LqzAjzDXPTTAbtkbexOfjgZktnnk9/jfH6+BYo= From: "WolfgaNg.Hospital at arcor dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114835] New: AVR popcountqi2 is not fast&small as can be Date: Wed, 24 Apr 2024 15:20:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: WolfgaNg.Hospital at arcor dot de 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 attachments.created 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=3D114835 Bug ID: 114835 Summary: AVR popcountqi2 is not fast&small as can be Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: WolfgaNg.Hospital at arcor dot de Target Milestone: --- Created attachment 58025 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D58025&action=3Dedit AVR assembly code for __popcountqi2 For 8-bit AVRs, the current 16-instruction __popcountqi2 uses 6 ADC instructions to establish the number of bits set in a byte.=20=20 In "Bit Twiddling Hacks", Sean E. Anderson presents several approaches to t= his; "parallel/sideways addition" can be coded with one instruction&cycle less. When establishing the "popcount" of an uint8_t, I've seen GCC to widen the value to "half int" and use __popcountqi2 twice.=