From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 079D7385B835 for ; Sat, 18 Apr 2020 18:46:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 079D7385B835 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-ehnjBOVoN9yzaGLB949Gbw-1; Sat, 18 Apr 2020 14:45:57 -0400 X-MC-Unique: ehnjBOVoN9yzaGLB949Gbw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B02F8017F6; Sat, 18 Apr 2020 18:45:56 +0000 (UTC) Received: from ovpn-112-84.phx2.redhat.com (ovpn-112-84.phx2.redhat.com [10.3.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D4BC5DA60; Sat, 18 Apr 2020 18:45:56 +0000 (UTC) Message-ID: <67c149bf174aa4562807050e48ee71508be2a47a.camel@redhat.com> Subject: Re: prevent zero-extension when using a memory load instruction From: Jeff Law Reply-To: law@redhat.com To: William Tambe , gcc-help Date: Sat, 18 Apr 2020 12:45:55 -0600 In-Reply-To: References: Organization: Red Hat User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Apr 2020 18:46:14 -0000 On Sat, 2020-04-18 at 14:36 -0400, William Tambe via Gcc-help wrote: > On Sat, Apr 18, 2020 at 11:32 AM Marc Glisse wrote: > > On Sat, 18 Apr 2020, William Tambe via Gcc-help wrote: > > > > > In the machine description file, is there a way to tell GCC that a > > > memory load instruction already zero-extend such that it does not try > > > to apply zero-extension ? > > > > I would look at it the other way around: you can tell GCC what asm to > > generate for a zero_extend with a memory operand. Or did you have a > > Thanks; tried above, but GCC still prefer a memory load followed by > zero-extension. > > The example code used is as follow: > > unsigned char var; > int main() { > return var; > } > > Also tried x86 and ARM GCC port to see what they produce, and find > that only x86 will not generate a zero-extension when -Os is used. > > The version of GCC used is 9.2.0. > > Any other suggestions on how to tell GCC not to zero-extend the result > of a memory load ? Many ports have this feature and it's discussed in the developer documentation. Please read it. jeff