From patchwork Mon Jun 7 21:02:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1489003 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=Qp8CvBk2; 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 4FzQpB4VVgz9sRK for ; Tue, 8 Jun 2021 07:03:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 963C43938C3B for ; Mon, 7 Jun 2021 21:03:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 963C43938C3B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623099822; bh=ISO5WO9B68mGI2q7Elc8nx9H8fA2mbYsO4wtddvtXGA=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Qp8CvBk2hjxhhrp2+vfPcIZjGGpeNJl7VP1a+vsVuEOWiC4YO0IZvfhKr8Hr9XeM1 3ayuPYuid3gKcfL/+/FJKh35XSL4Lfn6f3tUNTVA/Ic3X5fkqVvfuhWQt6+o4YN+HJ aKiF6ms/daGAaBOItr0i0RzoFvVWMOZI3DYQT21A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by sourceware.org (Postfix) with ESMTPS id 4DDB4388C02E for ; Mon, 7 Jun 2021 21:03:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4DDB4388C02E Received: by mail-qk1-x72f.google.com with SMTP id j189so18191467qkf.2 for ; Mon, 07 Jun 2021 14:03:00 -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:from:date:message-id:subject:to; bh=ISO5WO9B68mGI2q7Elc8nx9H8fA2mbYsO4wtddvtXGA=; b=L8z8IAVmG+B1V1phKmZ5ik9HXVe++o65xNvF2KpZ0KWNkUFPWTZ1yGAYcj0jlv2+ot 28WXa5FolftBju2ugqnRS3G024C2qA+5+NllFi9YTdmuCUF3XtSfm8PdcH8+f0iTQXtV 7gkWFKJG0DXyFgtrX+UyBU/up5xwM+0FHgejbiBUZywFdjBRW5RwSju3pcpqnSbAcTvR ajdzz4vM87N48tOnz5pbie41sUKjvqrCnnZL4iOtaAjLhl26PfW2+xKtQfyptn/u1o+A KH7R/ngAhkvOBx0OKYT0bpWa3yk2jM/10Dm5bgHnaSe59H8xpZYdqxtKsujR05uUbEwD egIg== X-Gm-Message-State: AOAM530TL716mGoQwYWugqWiRUGxLGgNF0ztSYOlnHORufF1orIr7Ezq fiqK9LOjr2I24H+C8ksxUHzYqOSgb/f+ecFArs12wumP5G4Bwg== X-Google-Smtp-Source: ABdhPJwmdR4Saam9t1BwQk/YWp99NH2r0a0xdntgklIYrFS7jfDaHhBl9Ka27/QyaA7DUcTEa/m5up3eM+PMnqG+3mM= X-Received: by 2002:a37:94e:: with SMTP id 75mr18523538qkj.127.1623099779591; Mon, 07 Jun 2021 14:02:59 -0700 (PDT) MIME-Version: 1.0 Date: Mon, 7 Jun 2021 23:02:48 +0200 Message-ID: Subject: [PATCH] i386: Add init pattern for V4QI vectors [PR100637] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 2021-06-07 Uroš Bizjak gcc/ PR target/100637 * config/i386/i386-expand.c (ix86_expand_vector_init_duplicate): Handle V4QI mode. (ix86_expand_vector_init_one_nonzero): Ditto. (ix86_expand_vector_init_one_var): Ditto. (ix86_expand_vector_init_general): Ditto. * config/i386/mmx.md (vec_initv4qiqi): New expander. gcc/testsuite/ PR target/100637 * gcc.target/i386/pr100637-5b.c: New test. * gcc.target/i386/pr100637-5w.c: Ditto. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Pushed to master. Uros. diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c index fb0676f1158..c3ce21b4387 100644 --- a/gcc/config/i386/i386-expand.c +++ b/gcc/config/i386/i386-expand.c @@ -13733,6 +13733,7 @@ ix86_expand_vector_init_duplicate (bool mmx_ok, machine_mode mode, return false; case E_V8QImode: + case E_V4QImode: if (!mmx_ok) return false; goto widen; @@ -13878,6 +13879,9 @@ ix86_expand_vector_init_one_nonzero (bool mmx_ok, machine_mode mode, case E_V4HImode: use_vector_set = TARGET_SSE || TARGET_3DNOW_A; break; + case E_V4QImode: + use_vector_set = TARGET_SSE4_1; + break; case E_V32QImode: case E_V16HImode: use_vector_set = TARGET_AVX; @@ -14086,6 +14090,10 @@ ix86_expand_vector_init_one_var (bool mmx_ok, machine_mode mode, break; wmode = V4HImode; goto widen; + case E_V4QImode: + if (TARGET_SSE4_1) + break; + wmode = V2HImode; widen: /* There's no way to set one QImode entry easily. Combine the variable value with its adjacent constant value, and @@ -14535,6 +14543,7 @@ quarter: case E_V8QImode: case E_V2HImode: + case E_V4QImode: break; default: diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index c3fd2805f25..0a17a54fad5 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -3369,7 +3369,17 @@ (match_operand 1)] "TARGET_SSE2" { - ix86_expand_vector_init (false, operands[0], + ix86_expand_vector_init (TARGET_MMX_WITH_SSE, operands[0], + operands[1]); + DONE; +}) + +(define_expand "vec_initv4qiqi" + [(match_operand:V2HI 0 "register_operand") + (match_operand 1)] + "TARGET_SSE2" +{ + ix86_expand_vector_init (TARGET_MMX_WITH_SSE, operands[0], operands[1]); DONE; }) diff --git a/gcc/testsuite/gcc.target/i386/pr100637-5b.c b/gcc/testsuite/gcc.target/i386/pr100637-5b.c new file mode 100644 index 00000000000..3e6cc8ff975 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr100637-5b.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2" } */ + +typedef char S; +typedef S V __attribute__((vector_size(4 * sizeof(S)))); + +V duplicate (S a) +{ + return (V) { a, a, a, a }; +} + +V one_nonzero (S a) +{ + return (V) { 0, a }; +} + +V one_var (S a) +{ + return (V) { 1, a }; +} + +V general (S a, S b, S c, S d) +{ + return (V) { a, b, c, d }; +} diff --git a/gcc/testsuite/gcc.target/i386/pr100637-5w.c b/gcc/testsuite/gcc.target/i386/pr100637-5w.c new file mode 100644 index 00000000000..3f677385c16 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr100637-5w.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2" } */ + +typedef short S; +typedef S V __attribute__((vector_size(2 * sizeof(S)))); + +V duplicate (S a) +{ + return (V) { a, a }; +} + +V one_nonzero (S a) +{ + return (V) { 0, a }; +} + +V one_var (S a) +{ + return (V) { 1, a }; +} + +V general (S a, S b) +{ + return (V) { a, b }; +}