From patchwork Mon Aug 9 15:23:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1515146 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@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=KbA2W0+T; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4Gk0Hs17J1z9shx for ; Tue, 10 Aug 2021 01:24:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5BA463896C24 for ; Mon, 9 Aug 2021 15:24:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5BA463896C24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628522675; bh=vTeocnxn/Z1ggKjnLrztDKY0qjl49UQE5kGtNZ45/UY=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=KbA2W0+TbAvwxXWLDNAiQoiaqEQmFzefv8DF35mYffGH1mrjal11dkt7HFyGXAtNI 0nUNvRo9WAUgSxYSeBFIMiCg2nxsW4yGztvylmAi/H+axddwGQ+VUlnICLwdmYuKHS XFgarqXeeVijuFPBwsHnfX/mNpYF7gv3CWG0Nmao= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id C110D385E019 for ; Mon, 9 Aug 2021 15:24:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C110D385E019 Received: by mail-pj1-x1034.google.com with SMTP id w13-20020a17090aea0db029017897a5f7bcso412396pjy.5 for ; Mon, 09 Aug 2021 08:24:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vTeocnxn/Z1ggKjnLrztDKY0qjl49UQE5kGtNZ45/UY=; b=dNB+Y0NWpy+IfXN5+TN2og4lMS4IWrAS0aZmwTDba/rfs66J5mUGc7prvGAASh2Md2 IJ8Uw11d3bZOS9g7nLXMUzhIFSRf1v7OE+DC95DFb06QFmVlB6MQ/XiuI6vz0zlsFjdz 9+oG1xkooX9ytDebBbq0wom8iKV94FduGegpv8RkkDujngSb9wS2Y7CxbvRJvnIsoGzD CwEjOAZy8l7pe2083Ian1Ds79x4BzHu5iEf9XLq8t8ZgV5LISwG8LaTbyIvXKiKzChAF 4zh4hgS5DMwYqZPuW31PKKDpLXyZFOpoXC8pp18Zvyd4y+nIW9CuIIdMJ5SNEq92M/Ct uXyg== X-Gm-Message-State: AOAM532rGw4UXaWtSSavW9kTjsRS1KL4wJMBTaOqTERuQfqn0AYk1f7m qFpaJRF4YO+GcHClgIz94PfKJ57lGybfybEwUSM= X-Google-Smtp-Source: ABdhPJx4AIpFJals96JFesNb2pDzDz5tK3LGa8QxPtvNlS1M2vnjesHNyePQAbfQVWvB3q8zXZ14uIr7fUg3Bh6b4Dw= X-Received: by 2002:a17:90a:4404:: with SMTP id s4mr16321629pjg.153.1628522652752; Mon, 09 Aug 2021 08:24:12 -0700 (PDT) MIME-Version: 1.0 References: <20210807144132.3645400-1-hjl.tools@gmail.com> In-Reply-To: Date: Mon, 9 Aug 2021 08:23:36 -0700 Message-ID: Subject: [PATCH v2] x86: Optimize load of const all 1s float vectors To: Uros Bizjak X-Spam-Status: No, score=-3031.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: "H.J. Lu via Gcc-patches" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: liuhongt , "gcc-patches@gcc.gnu.org" Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" On Sun, Aug 8, 2021 at 1:23 PM Uros Bizjak wrote: > > On Sat, Aug 7, 2021 at 4:41 PM H.J. Lu wrote: > > > > Update vector_all_ones_operand to return true for const all 1s float > > vectors. > > > > gcc/ > > > > PR target/101804 > > * config/i386/predicates.md (vector_all_ones_operand): Return > > true for const all 1s float vectors. > > > > gcc/testsuite/ > > > > PR target/101804 > > * gcc.target/i386/avx2-gather-2.c: Pass -march=skylake instead > > of "-mavx2 -mtune=skylake". Scan vpcmpeqd. > > No, vector_all_ones_operand is intended to be integer minus-one. Use > float_vector_all_ones_operand in a specific place, where it is needed. > Like this? From 017dee0c9ee946e16fbb1b938c1dd62ac0f95b09 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 6 Aug 2021 12:32:01 -0700 Subject: [PATCH v2] x86: Optimize load of const all 1s float vectors Check float_vector_all_ones_operand for vector floating-point modes to optimize load of const all 1s float vectors. gcc/ PR target/101804 * config/i386/constraints.md (BC): For vector floating-point modes, also check float_vector_all_ones_operand. * config/i386/i386.c (standard_sse_constant_p): Likewise. (standard_sse_constant_opcode): Likewise. gcc/testsuite/ PR target/101804 * gcc.target/i386/avx2-gather-2.c: Pass -march=skylake instead of "-mavx2 -mtune=skylake". Scan vpcmpeqd. --- gcc/config/i386/constraints.md | 4 +++- gcc/config/i386/i386.c | 11 +++++++++-- gcc/testsuite/gcc.target/i386/avx2-gather-2.c | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md index 4aa28a5621c..cb1a803ab87 100644 --- a/gcc/config/i386/constraints.md +++ b/gcc/config/i386/constraints.md @@ -219,7 +219,9 @@ (define_constraint "BC" "@internal SSE constant -1 operand." (and (match_test "TARGET_SSE") (ior (match_test "op == constm1_rtx") - (match_operand 0 "vector_all_ones_operand")))) + (match_operand 0 "vector_all_ones_operand") + (and (match_test "GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT") + (match_operand 0 "float_vector_all_ones_operand"))))) ;; Integer constant constraints. (define_constraint "Wb" diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index aea224ab235..4d4ab6a03d6 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5073,7 +5073,11 @@ standard_sse_constant_p (rtx x, machine_mode pred_mode) if (x == const0_rtx || const0_operand (x, mode)) return 1; - if (x == constm1_rtx || vector_all_ones_operand (x, mode)) + if (x == constm1_rtx + || vector_all_ones_operand (x, mode) + || ((GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT + || GET_MODE_CLASS (pred_mode) == MODE_VECTOR_FLOAT) + && float_vector_all_ones_operand (x, mode))) { /* VOIDmode integer constant, get mode from the predicate. */ if (mode == VOIDmode) @@ -5171,7 +5175,10 @@ standard_sse_constant_opcode (rtx_insn *insn, rtx *operands) gcc_unreachable (); } } - else if (x == constm1_rtx || vector_all_ones_operand (x, mode)) + else if (x == constm1_rtx + || vector_all_ones_operand (x, mode) + || (GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT + && float_vector_all_ones_operand (x, mode))) { enum attr_mode insn_mode = get_attr_mode (insn); diff --git a/gcc/testsuite/gcc.target/i386/avx2-gather-2.c b/gcc/testsuite/gcc.target/i386/avx2-gather-2.c index 1a704afd834..ad5ef73107c 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-gather-2.c +++ b/gcc/testsuite/gcc.target/i386/avx2-gather-2.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -mavx2 -fdump-tree-vect-details -mtune=skylake" } */ +/* { dg-options "-O3 -fdump-tree-vect-details -march=skylake" } */ #include "avx2-gather-1.c" /* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 16 "vect" } } */ +/* { dg-final { scan-assembler "vpcmpeqd" } } */ -- 2.31.1