From patchwork Mon Jun 14 18:58:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1491815 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=2620:52:3:1:0:246e:9693:128c; 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=bwjNZuk/; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G3gjp0bscz9sW4 for ; Tue, 15 Jun 2021 04:59:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7DFF3395C046 for ; Mon, 14 Jun 2021 18:59:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DFF3395C046 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623697177; bh=cPY0c+gJ3yOHsz70+QX6btCz8GUpp6QW7WRmxLzvKs8=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=bwjNZuk/uJIZoYi0m0MqqqKwaihoSKeGR7RRIHslWER8Zdx2MTD7BLtRbl2L7sJN/ 3LXJyz63GtXFo9LqtOz/UtGsJEZ99ASvjCGCAS+lclK0AwDwXzKKDiCONuznLd/PvC hhphFk6oj26ghUc/VlqKeHFRsM+6FwYwuPYV65zI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by sourceware.org (Postfix) with ESMTPS id 5205538515DA for ; Mon, 14 Jun 2021 18:58:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5205538515DA Received: by mail-qt1-x832.google.com with SMTP id r7so968196qta.12 for ; Mon, 14 Jun 2021 11:58:53 -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=cPY0c+gJ3yOHsz70+QX6btCz8GUpp6QW7WRmxLzvKs8=; b=Wz5G6MHsLYmQJ35a6B6jSTfUcJiHO95DFLzLB34D5uRDpFdlCkc3euq6NuiArjhR9Z 9z6qvcUIEOjlNjodKoPZKcy/15Ciw74OTkqEHifdt8VI4ryMY4wldciW+gWcDDHqdyKp qfgh8X9VgoRWX5GHYHnPL9Mei7TZOmmLH6sOIYficUEAIMvQmVbHZ3GXaXM5ReVfYBLQ t219i+6WNo7ReQxnivAnV04kxoSNLFPXgBv2R8yWLu3ru6ffGtGpck4oD7QYAcg+mggc iSBKzna8oS9cfwuh6lw6McxmOuelDeSS33tlmLWj0e9XfLA86gsS7m0AR4jai+hJfixC jzFA== X-Gm-Message-State: AOAM532RDOyY30D4ERgx7ebpK1THMPN14q/J8MJcxRLf3YFZkaikiP9e qO3kgyW8Y+Wj4GI+1yeMn9Z39K3UNYo4MGTJvOFFKK49nP3zUQ== X-Google-Smtp-Source: ABdhPJypueqVn44lzrzOOAaTk5eENRc76CL72oNgAwLQez+kbYSyvz94fWeCm1F50ezMFmZgHRyyAbbetCTgOmW9sZA= X-Received: by 2002:ac8:6686:: with SMTP id d6mr16834741qtp.51.1623697132550; Mon, 14 Jun 2021 11:58:52 -0700 (PDT) MIME-Version: 1.0 Date: Mon, 14 Jun 2021 20:58:41 +0200 Message-ID: Subject: [PATCH] i386: Split V2HImode *punpckwd to SSE instruction [PR101058] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-9.0 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" V2HImode *punpckwd should not be split to the insn that depends on TARGET_MMX_WITH_SSE, since the later is disabled on 32bit targets. Also return true early from ix86_vectorize_vec_perm_const when testing with V2HI mode. *punpckwd can be used to implement all permutations. 2021-06-14 Uroš Bizjak gcc/ PR target/101058 * config/i386/i386-expand.c (ix86_vectorize_vec_perm_const): Return true early when testing with V2HImode. * config/i386/mmx.md (*punpckwd): Split to sse2_pshuflw_1. gcc/testsuite/ PR target_101058 * gcc.target/i386/pr101058.c: New test. 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 6e33f6f8196..dee3df2e3a0 100644 --- a/gcc/config/i386/i386-expand.c +++ b/gcc/config/i386/i386-expand.c @@ -20446,9 +20446,12 @@ ix86_vectorize_vec_perm_const (machine_mode vmode, rtx target, rtx op0, return false; break; case E_V2HImode: - if (!TARGET_SSE2) - return false; - break; + if (!TARGET_SSE2) + return false; + /* All implementable with *punpckwd. */ + if (d.testing_p) + return true; + break; case E_V2DImode: case E_V2DFmode: if (!TARGET_SSE) diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index f9e7d2786c6..1a9e7b024dd 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -3368,16 +3368,18 @@ (define_insn_and_split "*punpckwd" (vec_concat:V4HI (match_operand:V2HI 1 "register_operand" "0,Yw") (match_operand:V2HI 2 "register_operand" "x,Yw")) - (parallel [(match_operand 3 "const_0_to_3_operand") - (match_operand 4 "const_0_to_3_operand")])))] + (parallel [(match_operand 3 "const_0_to_3_operand") + (match_operand 4 "const_0_to_3_operand")])))] "TARGET_SSE2" "#" "&& reload_completed" [(set (match_dup 5) - (vec_select:V4HI + (vec_select:V8HI (match_dup 5) (parallel [(match_dup 3) (match_dup 4) - (const_int 0) (const_int 0)])))] + (const_int 2) (const_int 3) + (const_int 4) (const_int 5) + (const_int 6) (const_int 7)])))] { rtx dest = lowpart_subreg (V8HImode, operands[0], V2HImode); rtx op1 = lowpart_subreg (V8HImode, operands[1], V2HImode); @@ -3395,8 +3397,7 @@ (define_insn_and_split "*punpckwd" operands[3] = GEN_INT (sel0); operands[4] = GEN_INT (sel1); - - operands[5] = lowpart_subreg (V4HImode, dest, V8HImode); + operands[5] = dest; } [(set_attr "isa" "noavx,avx") (set_attr "type" "sselog") diff --git a/gcc/testsuite/gcc.target/i386/pr101058.c b/gcc/testsuite/gcc.target/i386/pr101058.c new file mode 100644 index 00000000000..a2b251ce07d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr101058.c @@ -0,0 +1,12 @@ +/* PR target/101058 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -msse2 -mno-mmx" } */ + +short add90Hybrid_a_1; +short *add90Hybrid_b, *add90Hybrid_c, *add90Hybrid_d; +void add90Hybrid() { + for (int i; i < 200; i += 2) { + add90Hybrid_c[i] = add90Hybrid_b[i]; + add90Hybrid_d[i] = add90Hybrid_a_1 - add90Hybrid_b[i + 1]; + } +}