From patchwork Fri Mar 5 16:46:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1448031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Ez9Ead/m; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DsYYS39Lxz9sVt for ; Sat, 6 Mar 2021 03:47:07 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A5503874C14; Fri, 5 Mar 2021 16:47:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A5503874C14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1614962825; bh=8tRtnBTkFNfM5SAEHRAqIhWbhWSNQayJaUa1Te4aw90=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Ez9Ead/mWQz0YYmxTsg8Gy7UDibBlkvRpQteHJzcVpJN42jCcg8urEQPGrxIF5tVE f2O6TGO9vH66Wcg1ryoIjTeTAXfFEiRB1OO2v6EGaw0ugIfq4g9IaUawu2hZo61JR0 RZjpeD4iuy8WRzRATy785LZFIuZsXJkEZJQD9rkM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id BE21638618CC for ; Fri, 5 Mar 2021 16:47:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BE21638618CC 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-568-5qJRKsNyNfKZRHB8SZRXQg-1; Fri, 05 Mar 2021 11:46:57 -0500 X-MC-Unique: 5qJRKsNyNfKZRHB8SZRXQg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EE8D19200C0 for ; Fri, 5 Mar 2021 16:46:56 +0000 (UTC) Received: from [10.10.115.99] (ovpn-115-99.rdu2.redhat.com [10.10.115.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52E2F6091A for ; Fri, 5 Mar 2021 16:46:55 +0000 (UTC) Subject: [commited] [PR99378] LRA: Skip decomposing address for asm insn operand with unknown constraint To: "gcc-patches@gcc.gnu.org" Message-ID: Date: Fri, 5 Mar 2021 11:46:55 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Vladimir Makarov via Gcc-patches From: Vladimir Makarov Reply-To: Vladimir Makarov Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99378   The patch was successfully bootstrapped and tested on x86-64. commit e786c7547eda4edd90797f6cae0f5e6405d64773 (HEAD -> master) Author: Vladimir N. Makarov Date: Fri Mar 5 11:41:25 2021 -0500 [PR99378] LRA: Skip decomposing address for asm insn operand with unknown constraint. Function get_constraint_type returns CT__UNKNOWN for empty constraint and CT_FIXED_FORM for "X". So process_address_1 skipped decompose_mem_address only for "X" constraint. To do the same for empty constraint, skip decompose_mem_address for CT__UNKNOWN. gcc/ChangeLog: PR target/99378 * lra-constraints.c (process_address_1): Skip decomposing address for asm insn operand with unknown constraint. gcc/testsuite/ChangeLog: PR target/99378 * gcc.target/i386/pr99123-2.c: New. diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 51acf7f0701..9253690561a 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -3450,8 +3450,9 @@ process_address_1 (int nop, bool check_only_p, i.e. bcst_mem_operand in i386 backend. */ else if (MEM_P (mem) && !(INSN_CODE (curr_insn) < 0 - && get_constraint_type (cn) == CT_FIXED_FORM - && constraint_satisfied_p (op, cn))) + && (cn == CONSTRAINT__UNKNOWN + || (get_constraint_type (cn) == CT_FIXED_FORM + && constraint_satisfied_p (op, cn))))) decompose_mem_address (&ad, mem); else if (GET_CODE (op) == SUBREG && MEM_P (SUBREG_REG (op))) diff --git a/gcc/testsuite/gcc.target/i386/pr99123-2.c b/gcc/testsuite/gcc.target/i386/pr99123-2.c new file mode 100644 index 00000000000..def4eae3c9d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99123-2.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funroll-loops" } */ + +static inline void * +baz (void *s, unsigned long c, unsigned int count) +{ + int d0, d1; + __asm__ __volatile__ ("" + : "=&c" (d0), "=&D" (d1) + :"a" (c), "q" (count), "0" (count / 4), "" ((long) s) /// "1" + :"memory"); + return s; +} + +struct A +{ + unsigned long *a; +}; + +inline static void * +bar (struct A *x, int y) +{ + char *ptr; + + ptr = (void *) x->a[y >> 12]; + ptr += y % (1UL << 12); + return (void *) ptr; +} + +int +foo (struct A *x, unsigned int *y, int z, int u) +{ + int a, b, c, d, e; + + z += *y; + c = z + u; + a = (z >> 12) + 1; + do + { + b = (a << 12); + d = b - z; + e = c - z; + if (e < d) + d = e; + baz (bar (x, z), 0, d); + z = b; + a++; + } + while (z < c); + return 0; +}