From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 11613385841B; Wed, 28 Jun 2023 15:05:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11613385841B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687964753; bh=fkILYnknifcUIz97+pI8em64hd12Jw4mfWcopZvJ8SY=; h=From:To:Subject:Date:From; b=MnOV0x/FKezT9Eia1Nnnzcc+e2zjv1hPFVKWrECX/D9qxopldqwRbY/m8EMnVn+tu LcIKz/WP/Nev1lpFbzRsqvqklzEwzNE813Cem6D13vXM9Hfedieg7VE8Bzj0d56JgM zLzePQMNQsyugaK5ntu8IoOV2Fx2Y2+/7xAWhXWc= From: "antoshkka at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/110457] New: Unnecessary movsx eax, dil Date: Wed, 28 Jun 2023 15:05:52 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: antoshkka at gmail dot com 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 keywords bug_severity priority component assigned_to reporter target_milestone 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=3D110457 Bug ID: 110457 Summary: Unnecessary movsx eax, dil Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- For the following code int sample1(char c) { return (c << 4) + (c << 8) + (c << 16) + c; } GCC-14 with -O2 generates the assembly: sample1(char): movsx eax,dil imul eax,eax,0x10111 ret However, it could be shortened to just: sample1(char): imul eax,edi,0x10111 Godbolt playground: https://godbolt.org/z/7GGdedEY8=