Message ID | 00b801d91a50$30a62140$91f263c0$@nextmovesoftware.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1639740wrt; Tue, 27 Dec 2022 16:06:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXu8f5GtJY+63MrLNLqVv8xwlOzfOLRhRfq0sp9OEjZ13sd3w/YdzHCfbfX398CnyBGZdT83 X-Received: by 2002:a05:6402:448a:b0:481:9219:f603 with SMTP id er10-20020a056402448a00b004819219f603mr13920954edb.28.1672186018792; Tue, 27 Dec 2022 16:06:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672186018; cv=none; d=google.com; s=arc-20160816; b=E+C4JAT4NbLlGTg+OTU8mEs6ghQagq5cWPecvLE7v7Ple4FKtVpXAw8t2P2c8+AdhK RuZK/QluXmRUuo++qTv9FAe/dYg1JoOzL8rDPS+fpSFCWMtjCo5DmRf04f02kF+Ur7ar NzBXaojhOGdud6XSemNJHX0iHh8EnGg+tdfVyfoyT/+1optGPUBZ4GWXRmVuKEM4/G3C 8fFROFw+vBUYnOotJ7vinc4yigcMuFFmibJO8VmQ5C8mn7vCfAgJEyHR3fjCV9Q/A9+f y3iqZ/el6NXk18+DOkikhB9kRPRGfmy8NdQpMGv1eGLIk5VpQ4K6OyvntopWhGtZLxbR rMRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-language:thread-index :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=jVrY6/OnGE0eC6kGhDrx5zeCP5FqtJlCa1q3hEKlvMc=; b=Whma7YTVy9swGasN7ZmPEY5C/eg9Q7vK6U9/szup+fZPPd6wI4Idj+H0ioYaSkhV4P mLMNQxDSk9AtlPZvTlwU+W6N7gi4LSEcEkw5kWWSogdJ2eYm8crmsfCtuMXn8C6jbXHp cnDp80lR9TwDrrLf3TF75C55b8tsEjLldmGZHwDPKLX27bC6kfUML86wMm8U1V+XKPAU GdPmvuUtEsC6V6Lzvi8Ik5EKJuzf/DLVpcVreXHiyvfZToTyjWYdUAdXR2zPChSgvd23 kkeoEJ5vxwRwT8Tygy4mipd5wmkQeKtLeHRnlL05WS9Ud52AYj7jYUGCAt2/j+jKLRSM L5uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=l5S9zM6g; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m13-20020a056402510d00b0044f2fb68fe6si12844537edd.495.2022.12.27.16.06.58 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 16:06:58 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=l5S9zM6g; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA784385B52D for <ouuuleilei@gmail.com>; Wed, 28 Dec 2022 00:06:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 5FA743858C39 for <gcc-patches@gcc.gnu.org>; Wed, 28 Dec 2022 00:06:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5FA743858C39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=jVrY6/OnGE0eC6kGhDrx5zeCP5FqtJlCa1q3hEKlvMc=; b=l5S9zM6gik4AdwNObx3PTC79KT ujl/K+vWa5IuoRgmGUXqguhJfT6aac9sO3A92Yb45IZ6fMyUd7hUuIDQwXtW25Tcr9LMWiUoMsQTF tNkZZHjIRmJP2+b/mVVDWMPRW194DZhKxgyxf5un2xcfixodtjUjFVQXQpGpcfu1wdBlUfrf3TLVh mKAPaSBdGmRa1r1LnxwqL4HqT57VO6MWt+UgD+/f1krfiXuuvaE+Z7ZBKQeF7OGSYeub9RTi7S1bj tB1K+WvCQRRscURcDU/q2licH1+/LDHh0S9iUo8Vh9eXe/jbqrWMhv/CCVnasADh9TtHY5hK3MSCv uwpCpl+Q==; Received: from host109-151-228-216.range109-151.btcentralplus.com ([109.151.228.216]:50917 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from <roger@nextmovesoftware.com>) id 1pAJxS-0007HS-9J; Tue, 27 Dec 2022 19:06:10 -0500 From: "Roger Sayle" <roger@nextmovesoftware.com> To: "'GCC Patches'" <gcc-patches@gcc.gnu.org> Cc: "'Uros Bizjak'" <ubizjak@gmail.com> Subject: [x86 PATCH] Use ix86_expand_clear in ix86_split_ashl. Date: Wed, 28 Dec 2022 00:06:08 -0000 Message-ID: <00b801d91a50$30a62140$91f263c0$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_00B9_01D91A50.30A62140" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdkaT8vhUd+UEltaRheNE3lKSI+X6A== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753414126409404447?= X-GMAIL-MSGID: =?utf-8?q?1753414126409404447?= |
Series |
[x86] Use ix86_expand_clear in ix86_split_ashl.
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Roger Sayle
Dec. 28, 2022, 12:06 a.m. UTC
This patch is a one line change, to call ix86_expand_clear instead of emit_move_insn with const0_rtx in ix86_split_ashl, allowing the backend to use an xor instruction to clear a register if appropriate. The effect is demonstrated with the following function. __int128 foo(__int128 x, unsigned long long b) { return ((__int128)b << 72) + x; } previously with -O2, GCC would generate foo: movl $0, %eax salq $8, %rdx addq %rdi, %rax adcq %rsi, %rdx ret with this patch, it now generates foo: xorl %eax, %eax salq $8, %rdx addq %rdi, %rax adcq %rsi, %rdx ret This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check, both with and without --target_board=unix{-m32}, with no new failures. It's an independent piece of a larger bug fix. Ok for mainline? 2022-12-28 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/i386/i386-expand.cc (ix86_split_ashl): Call ix86_expand_clear to generate an xor instruction. gcc/testsuite/ChangeLog * gcc.target/i386/ashlti3-1.c: New test case. Thanks in advance, Roger --
Comments
On Wed, Dec 28, 2022 at 1:06 AM Roger Sayle <roger@nextmovesoftware.com> wrote: > > This patch is a one line change, to call ix86_expand_clear instead of > emit_move_insn with const0_rtx in ix86_split_ashl, allowing the backend > to use an xor instruction to clear a register if appropriate. > > The effect is demonstrated with the following function. > __int128 foo(__int128 x, unsigned long long b) { > return ((__int128)b << 72) + x; > } > > previously with -O2, GCC would generate > > foo: movl $0, %eax > salq $8, %rdx > addq %rdi, %rax > adcq %rsi, %rdx > ret > > with this patch, it now generates > > foo: xorl %eax, %eax > salq $8, %rdx > addq %rdi, %rax > adcq %rsi, %rdx > ret > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check, both with and without --target_board=unix{-m32}, > with no new failures. It's an independent piece of a larger bug fix. > Ok for mainline? > > > 2022-12-28 Roger Sayle <roger@nextmovesoftware.com> > > gcc/ChangeLog > * config/i386/i386-expand.cc (ix86_split_ashl): Call > ix86_expand_clear to generate an xor instruction. > > gcc/testsuite/ChangeLog > * gcc.target/i386/ashlti3-1.c: New test case. OK. Thanks, Uros. > > > Thanks in advance, > Roger > -- >
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index b6cc76d..3eddbc9 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -6211,7 +6211,7 @@ ix86_split_ashl (rtx *operands, rtx scratch, machine_mode mode) if (count >= half_width) { emit_move_insn (high[0], low[1]); - emit_move_insn (low[0], const0_rtx); + ix86_expand_clear (low[0]); if (count > half_width) ix86_expand_ashl_const (high[0], count - half_width, mode); diff --git a/gcc/testsuite/gcc.target/i386/ashlti3-1.c b/gcc/testsuite/gcc.target/i386/ashlti3-1.c new file mode 100644 index 0000000..1cf1306 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/ashlti3-1.c @@ -0,0 +1,6 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2" } */ +__int128 foo(__int128 x, unsigned long long b) { + return ((__int128)b << 72) + x; +} +/* { dg-final { scan-assembler-not "\tmovl\[ \\t\]+\\\$0," } } */