From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by sourceware.org (Postfix) with ESMTPS id 100123858C62 for ; Sun, 31 Jul 2022 17:22:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 100123858C62 Received: by mail-qt1-x82d.google.com with SMTP id a9so6506353qtw.10 for ; Sun, 31 Jul 2022 10:22:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=qi512F1/Io1sY7b0HTJHpvbPZ8pFblBZ629zYgKkMLA=; b=J3mgAzeucoKlyONaa/ixM1Q4C/o801iERSgnk9SBBPFA4w2aLx4G22L6LE0379zb40 NvPIsImEBLCK8npL8+VdRLFRAQIspi4MHBcFPG1UoymzxKQY/V47UCt1w8PTa8Z78coS 4AXDsJGtCCFoyF/44qoYpaj0xRl8ZKsEb9iTB7JMGpHO9ulNWkiugxNmP67AzuOGsn+0 5E8FlfhTW+HkS3FJWtTGtegGVIeNph5vkyWKsMcoP/jlujMz0JOSfusJtvcJzbJr9h2F Ex/uKTivG0uA5rYLs2aM29kBcf9C6fseDX7USRyEL/cFrovuPsR1vzPP4APoyQGxx7K+ /CMA== X-Gm-Message-State: AJIora/kh6ngCogdfjmnBRDH5qGtib5WxFen748d/BQ0x5XOp6I0Uwzp 1XSoJdK8Oi6Nwhug/cGqf+9/qiEaUIKviY1TOB4GuzYYrDXMiYhq X-Google-Smtp-Source: AGRyM1sJnLy8/Ks2jFsCpIxWIus8c5TXwejNRPdyFkblM5Y0VRyG571F61c4E9+1DojnHzSxtBEwW1r1TCEvE1k5/kQ= X-Received: by 2002:ac8:5a84:0:b0:31e:f60e:3449 with SMTP id c4-20020ac85a84000000b0031ef60e3449mr10803972qtc.57.1659288162955; Sun, 31 Jul 2022 10:22:42 -0700 (PDT) MIME-Version: 1.0 References: <032901d8a2cf$fc07cfd0$f4176f70$@nextmovesoftware.com> In-Reply-To: <032901d8a2cf$fc07cfd0$f4176f70$@nextmovesoftware.com> From: Uros Bizjak Date: Sun, 31 Jul 2022 19:22:31 +0200 Message-ID: Subject: Re: [x86 PATCH] Support logical shifts by (some) integer constants in TImode STV. To: Roger Sayle Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Jul 2022 17:22:45 -0000 On Fri, Jul 29, 2022 at 12:18 AM Roger Sayle wrote: > > > This patch improves TImode STV by adding support for logical shifts by > integer constants that are multiples of 8. For the test case: > > __int128 a, b; > void foo() { a = b << 16; } > > on x86_64, gcc -O2 currently generates: > > movq b(%rip), %rax > movq b+8(%rip), %rdx > shldq $16, %rax, %rdx > salq $16, %rax > movq %rax, a(%rip) > movq %rdx, a+8(%rip) > ret > > with this patch we now generate: > > movdqa b(%rip), %xmm0 > pslldq $2, %xmm0 > movaps %xmm0, a(%rip) > 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. Ok for mainline? > > > 2022-07-28 Roger Sayle > > gcc/ChangeLog > * config/i386/i386-features.cc (compute_convert_gain): Add gain > for converting suitable TImode shift to a V1TImode shift. > (timode_scalar_chain::convert_insn): Add support for converting > suitable ASHIFT and LSHIFTRT. > (timode_scalar_to_vector_candidate_p): Consider logical shifts > by integer constants that are multiples of 8 to be candidates. > > gcc/testsuite/ChangeLog > * gcc.target/i386/sse4_1-stv-7.c: New test case. + case ASHIFT: + case LSHIFTRT: + /* For logical shifts by constant multiples of 8. */ + igain = optimize_insn_for_size_p () ? COSTS_N_BYTES (4) + : COSTS_N_INSNS (1); Isn't the conversion an universal win for -O2 as well as for -Os? The conversion to/from XMM register is already accounted for, so for -Os substituting shldq/salq with pslldq should always be a win. I'd expect the cost calculation to be similar to the general_scalar_chain::compute_convert_gain cost calculation with m = 2. Uros.