From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B355C3858C54; Wed, 12 Apr 2023 16:48:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B355C3858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681318136; bh=axmPUUbYzRYq489KDhPWyF2/2smUMbfdXALpxdH4+KE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Xs+5m1McWw61CneSEEZ4mB6neeY+sdOoPQ1q/77sP58gdfLDlvotL7agQQHSlaQEY Hl77RtC+GanxdLTiPiNasg9dXO+DkuoiE84SguSikO/QguuZKIP92KSKyBHkAiKxTB hVnAq2LK704abIgL2AIMn1G1QtSXlX6nzAtK1FbM= From: "klaus.doldinger64 at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/109476] Missing optimization for 8bit/8bit multiplication / regression Date: Wed, 12 Apr 2023 16:48:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: klaus.doldinger64 at googlemail 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=3D109476 --- Comment #6 from Wilhelm M --- The following "solution" constexpr uint16_t mul(const uint8_t a, const uint16_t b) { const auto aa =3D std::bit_cast>(b); return aa[1] * a; } or=20 constexpr uint16_t mul(const uint8_t a, const uint16_t b) { uint8_t aa[2]; std::memcpy(aa, &b, 2); return aa[1] * a; } gives optimal result ;-)=