From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 18B70395BC79; Sat, 18 Apr 2020 00:50:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18B70395BC79 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587171009; bh=qMv3uaZUerYO4N9VLfjiAKAMvl+WZ67s/VbTsz9J5pM=; h=From:To:Subject:Date:From; b=kHW4sY7QaPjtFoP5Cz79pq13M5p82LS0mJVNlfXSjQwzCZ8p2osrwVEYRwMwzBz5x oyeGg87j7A5xLwOwE+Cc7ivocV2l4V2nuN+MsSjfMI7M5fwiuKdi6VP32FD9r2jSnW 346hu6zyTk6LcYRISBQkhPabW6v4QXkJM2L9hxNA= From: "bugdal at aerifal dot cx" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/94643] New: [x86_64] gratuitous sign extension of nonnegative value from 32 to 64 bits Date: Sat, 18 Apr 2020 00:50:08 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bugdal at aerifal dot cx 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 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Apr 2020 00:50:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94643 Bug ID: 94643 Summary: [x86_64] gratuitous sign extension of nonnegative value from 32 to 64 bits Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: bugdal at aerifal dot cx Target Milestone: --- Test case: #include uint16_t a[]; uint64_t f(int i) { return a[i]*16; } Produces: movslq %edi, %rdi movzwl a(%rdi,%rdi), %eax sall $4, %eax cltq ret The value is necessarily in the range [0,1M) (in particular, nonnegative) a= nd operation on eax has already cleared the upper bits of rax, so cltq is completely gratuitous. I've observed the same in nontrivial examples where movslq gets used.=