From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by sourceware.org (Postfix) with ESMTPS id 256AF3858010 for ; Mon, 23 May 2022 10:49:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 256AF3858010 Received: by mail-qt1-x82b.google.com with SMTP id m13so6238777qtx.0 for ; Mon, 23 May 2022 03:49:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vd6oZQzuPCKXTKqPMNfjxk8V4ooivC92PaoB0tsRNXA=; b=KYNMwEvn0QJN6oD9HmRjpFgS7KZTac7IacZthyW7tCxSjpDsm+FEbypBdCm+CE40pl kYLLUOW/EsTtzTm27+8/TFXQVKWVw941xSgPTsz+bEySHLqrhy/xaCNQg69x6tkzsQI3 ZDKHDkIuDo/lwnTtYclgoGxyPflcb7RWAFsqB7o6rxMByTbXgsYYfyATv5Tun2bCMWVT 6NUX3D5kszPxRIKmCd9Gg7Y1QV147hqH7yxjzV1RsQRgpN1Jo7H5G+EEB9C3MfsZLt2X dM9lDq5mp3Ncnsn7I0Xm0ZQOKUe0vc0VL52+RYtM9jvkZ1P7MgOAgEHFsYtXNuez/Rfz sbgQ== X-Gm-Message-State: AOAM532EcDECLQqbrC7WlWyM+jq4BxnPu5Flzc901dBGBwHxfVrQTu05 GChqskZ0iyIKviT/WVXTqKC6JlRmuIQqbICyggLBlRnLe/o= X-Google-Smtp-Source: ABdhPJyE+Lvekz1u462P/lPcsh/RqpK2hwD7xxdlkLbM97bgSC3KvNq1tS1LBWFBJnerj/OXva9y8hH6HR/xwxh/Zbo= X-Received: by 2002:a05:622a:64e:b0:2f3:f4a2:f3cb with SMTP id a14-20020a05622a064e00b002f3f4a2f3cbmr15802162qtb.626.1653302990458; Mon, 23 May 2022 03:49:50 -0700 (PDT) MIME-Version: 1.0 References: <008401d86d27$d74f9a20$85eece60$@nextmovesoftware.com> In-Reply-To: <008401d86d27$d74f9a20$85eece60$@nextmovesoftware.com> From: Richard Biener Date: Mon, 23 May 2022 12:49:39 +0200 Message-ID: Subject: Re: [PATCH] Simplify vec_unpack of uniform_vector_p constructors in match.pd. To: Roger Sayle , Richard Sandiford Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: Mon, 23 May 2022 10:49:53 -0000 On Sat, May 21, 2022 at 5:31 PM Roger Sayle wrote: > > > This patch simplifies vec_unpack_hi_expr/vec_unpack_lo_expr of a uniform > constructor or vec_duplicate operand. The motivation is from PR 105621 > where after optimization, we're left with: > > vect_cst__21 = {c_8(D), c_8(D), c_8(D), c_8(D)}; > vect_iftmp.7_4 = [vec_unpack_hi_expr] vect_cst__21; > > It turns out that there are no constant folding/simplification patterns > in match.pd, but the above can be simplified further to the equivalent: > > _20 = (long int) c_8(D); > vect_iftmp.7_4 = [vec_duplicate_expr] _20; > > which on x86-64 results in one less instruction, replacing pshufd $0 > then punpackhq, with punpcklqdq. This transformation is also useful > for helping CSE to spot that unpack_hi and unpack_lo are equivalent. > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check with no new failures. Ok for mainline? I think we need a way to query whether the target can do a VEC_DUPLICATE_EXPR. Currently we only ever have them for VL vectors and expand via expand_vector_broadcast which eventually simply gives up when there's no vec_duplicate or vec_init optabs suitable. IIRC with the VEC_PERM extension we should be able to handle VEC_DUPLICATE via VEC_PERM? (but we don't yet accept a scalar input, just V1?) I see most targets have picked up vec_duplicate but sparc, but still we'd need to check the specific mode. I think we can disregart vec_init checking and only apply the transforms when vec_duplicate is available. Richard. > > 2022-05-21 Roger Sayle > > gcc/ChangeLog > * match.pd (simplify vec_unpack_hi): Simplify VEC_UNPACK_*_EXPR > of uniform vector constructors and vec_duplicate. > > gcc/testsuite/ChangeLog > * g++.dg/vect/pr105621.cc: New test case. > > > Thanks in advance, > Roger > -- >