From patchwork Wed Jul 24 07:57:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 1964186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Wus851Dq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WTRGN1T6Hz1yZw for ; Wed, 24 Jul 2024 17:58:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5660F3858289 for ; Wed, 24 Jul 2024 07:58:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by sourceware.org (Postfix) with ESMTPS id 203393858D37 for ; Wed, 24 Jul 2024 07:57:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 203393858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 203393858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721807880; cv=none; b=RAFRa+eNOEGUKeM1x/bB5bOcvqIpMdUTxJDomdVbAA99NIfD1clXfKEbTVp0Rjos1FO6LTYOx8I3HSi6e2occmeutOgfThHuV326GymAaX2M6fgPY5GVvTXev4o98za/NApqjFk9msLoOql6IYfeg6Mn40xOnMKvY33WOqLTSp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721807880; c=relaxed/simple; bh=GrZkbnltL3wRjFGgk+ie6R2pQzT3GNHle2q/HucI2Ms=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=wZZ9SAl7NgBOJ/HbqAcz+9MoFxZQSfmSOoNXEw0S9frCMBRp8bl+mTo6reGqWL1+2LsctggLIn42YBL4ZJjRChYyEFs7zCNCgGWrxZgtp9LIujqvQ0D2van8FD8oop53jbz2xSQdCjc+fZ72h3MFYF14Sbysk7b+Qhkt5htNg5c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721807878; x=1753343878; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GrZkbnltL3wRjFGgk+ie6R2pQzT3GNHle2q/HucI2Ms=; b=Wus851Dq+/N9DAh241/yIry1C8Ov6+0UswSkcHszY09PPY5FexbxGIM8 H/KUjCCgGLgSpPN5qUh3BDLWHxOa1SMWcOb1WxtHmCEGfOT4TPYoj5csK nKJt3T07E3gM0jKkc+tqt8ez6AHYehfC2p11O+g1X2t7e6FSwacRd0LlQ mhDgpVUPBql1xxgChinPR9hMG4+BieZjhJjYuXD3nDLiFu6Q8uL3PapKY MqDaI8bfIryBHknW68uBp/Y0sbQFRaGh+BPYlpFR2A9VQzegw2im+W47e 6ZGqbZVSZkyJW883BoJnuR/bjsen/0GSDO75gaLN9CZa0Wr2b4DhJIR23 w==; X-CSE-ConnectionGUID: +zKrSot3TVa9WX9gug5E3w== X-CSE-MsgGUID: FpkPfJU5R2OAMF5fHf0LzA== X-IronPort-AV: E=McAfee;i="6700,10204,11142"; a="19653466" X-IronPort-AV: E=Sophos;i="6.09,232,1716274800"; d="scan'208";a="19653466" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2024 00:57:57 -0700 X-CSE-ConnectionGUID: 8ERYyGWIQ+6qde6DyCiyVA== X-CSE-MsgGUID: NlJ6oxf0Sgy6oIT5Qb6WOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,232,1716274800"; d="scan'208";a="52738380" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orviesa006.jf.intel.com with ESMTP; 24 Jul 2024 00:57:55 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id C547F1006FE0; Wed, 24 Jul 2024 15:57:54 +0800 (CST) From: liuhongt To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com Subject: [PATCH] [x86]Refine constraint "Bk" to define_special_memory_constraint. Date: Wed, 24 Jul 2024 15:57:54 +0800 Message-Id: <20240724075754.3967689-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org For below pattern, RA may still allocate r162 as v/k register, try to reload for address with leaq __libc_tsd_CTYPE_B@gottpoff(%rip), %rsi which result a linker error. (set (reg:DI 162) (mem/u/c:DI (const:DI (unspec:DI [(symbol_ref:DI ("a") [flags 0x60] )] UNSPEC_GOTNTPOFF)) Quote from H.J for why linker issue an error. >What do these do: > > leaq __libc_tsd_CTYPE_B@gottpoff(%rip), %rax > vmovq (%rax), %xmm0 > >From x86-64 TLS psABI: > >The assembler generates for the x@gottpoff(%rip) expressions a R X86 >64 GOTTPOFF relocation for the symbol x which requests the linker to >generate a GOT entry with a R X86 64 TPOFF64 relocation. The offset of >the GOT entry relative to the end of the instruction is then used in >the instruction. The R X86 64 TPOFF64 relocation is pro- cessed at >program startup time by the dynamic linker by looking up the symbol x >in the modules loaded at that point. The offset is written in the GOT >entry and later loaded by the addq instruction. > >The above code sequence looks wrong to me. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk and backport? gcc/ChangeLog: PR target/116043 * config/i386/constraints.md (Bk): Refine to define_special_memory_constraint. gcc/testsuite/ChangeLog: * gcc.target/i386/pr116043.c: New test. --- gcc/config/i386/constraints.md | 2 +- gcc/testsuite/gcc.target/i386/pr116043.c | 33 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr116043.c diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md index 7508d7a58bd..b760e7c221a 100644 --- a/gcc/config/i386/constraints.md +++ b/gcc/config/i386/constraints.md @@ -187,7 +187,7 @@ (define_special_memory_constraint "Bm" "@internal Vector memory operand." (match_operand 0 "vector_memory_operand")) -(define_memory_constraint "Bk" +(define_special_memory_constraint "Bk" "@internal TLS address that allows insn using non-integer registers." (and (match_operand 0 "memory_operand") (not (match_test "ix86_gpr_tls_address_pattern_p (op)")))) diff --git a/gcc/testsuite/gcc.target/i386/pr116043.c b/gcc/testsuite/gcc.target/i386/pr116043.c new file mode 100644 index 00000000000..76553496c10 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr116043.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512bf16 -O3" } */ +/* { dg-final { scan-assembler-not {(?n)lea.*@gottpoff} } } */ + +extern __thread int a, c, i, j, k, l; +int *b; +struct d { + int e; +} f, g; +char *h; + +void m(struct d *n) { + b = &k; + for (; n->e; b++, n--) { + i = b && a; + if (i) + j = c; + } +} + +char *o(struct d *n) { + for (; n->e;) + return h; +} + +int q() { + if (l) + return 1; + int p = *o(&g); + m(&f); + m(&g); + l = p; +}