From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 7745238930FB for ; Mon, 21 Jun 2021 08:34:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7745238930FB Received: by mail-ej1-x633.google.com with SMTP id gb32so19263307ejc.2 for ; Mon, 21 Jun 2021 01:34:44 -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=6mtThZTzSIUOGxC9f8aeqHgudHFW7DBOT1jx2hZ++hw=; b=hQZ1kBMhtcwWqrmiBktT+iXuNl5cZYgW4BN8Ls/5/cROTcJnbp2ckQqOXJ6zAxry+H dtUy+m3xbO01PHaEqvUTf2abjdVVSZ2IIaINYV/I/E6LGjQbbhmp2Ar/sy2tt8N4xAx/ 50Dm+0rDbX327WUiHjzSfGx0gCPqt1Ydtmq2+coahK7GvB348c0aEFrQTr6JsuYnU4Fw TqriQae4dQtFOldxBT3SGRkVoAkxa7a/IPRZruaIAboetkVSwRwrABkZ0pm4BKI89nE0 uNWhOUP/fQEZbkEshKBJjvnDc9Nwmqdyh7tqN3VkTbOFJCjW8ZOSsbXolN0BD0lfIR17 m8eg== X-Gm-Message-State: AOAM533XKS3OXkUWbcwADhDIL8odmW4ffZzBc73zRb+nelUs1fjTl2jo vfrQuuC6I63fHjPcSIKv+nwBCMk5/UKTbXGb2rh1+w== X-Google-Smtp-Source: ABdhPJzmxCfIdwRX28feSIrMCi1EN77nzyOebYWNags2jWg82V1ug5CF48gTURNziWWWa+yBppLG6t4CJA0pWea5ns4= X-Received: by 2002:a17:907:3fa7:: with SMTP id hr39mr1573068ejc.23.1624264483574; Mon, 21 Jun 2021 01:34:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Prathamesh Kulkarni Date: Mon, 21 Jun 2021 14:04:07 +0530 Message-ID: Subject: Re: [ARM] PR98435: Missed optimization in expanding vector constructor To: Christophe Lyon Cc: gcc Patches , Kyrill Tkachov Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, 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-List-Received-Date: Mon, 21 Jun 2021 08:34:46 -0000 On Mon, 14 Jun 2021 at 13:31, Prathamesh Kulkarni wrote: > > On Wed, 9 Jun 2021 at 15:58, Prathamesh Kulkarni > wrote: > > > > On Fri, 4 Jun 2021 at 13:15, Christophe Lyon wrote: > > > > > > On Fri, 4 Jun 2021 at 09:27, Prathamesh Kulkarni via Gcc-patches > > > wrote: > > > > > > > > Hi, > > > > As mentioned in PR, for the following test-case: > > > > > > > > #include > > > > > > > > bfloat16x4_t f1 (bfloat16_t a) > > > > { > > > > return vdup_n_bf16 (a); > > > > } > > > > > > > > bfloat16x4_t f2 (bfloat16_t a) > > > > { > > > > return (bfloat16x4_t) {a, a, a, a}; > > > > } > > > > > > > > Compiling with arm-linux-gnueabi -O3 -mfpu=neon -mfloat-abi=softfp > > > > -march=armv8.2-a+bf16+fp16 results in f2 not being vectorized: > > > > > > > > f1: > > > > vdup.16 d16, r0 > > > > vmov r0, r1, d16 @ v4bf > > > > bx lr > > > > > > > > f2: > > > > mov r3, r0 @ __bf16 > > > > adr r1, .L4 > > > > ldrd r0, [r1] > > > > mov r2, r3 @ __bf16 > > > > mov ip, r3 @ __bf16 > > > > bfi r1, r2, #0, #16 > > > > bfi r0, ip, #0, #16 > > > > bfi r1, r3, #16, #16 > > > > bfi r0, r2, #16, #16 > > > > bx lr > > > > > > > > This seems to happen because vec_init pattern in neon.md has VDQ mode > > > > iterator, which doesn't include V4BF. In attached patch, I changed > > > > mode > > > > to VDQX which seems to work for the test-case, and the compiler now generates: > > > > > > > > f2: > > > > vdup.16 d16, r0 > > > > vmov r0, r1, d16 @ v4bf > > > > bx lr > > > > > > > > However, the pattern is also gated on TARGET_HAVE_MVE and I am not > > > > sure if either VDQ or VDQX are correct modes for MVE since MVE has > > > > only 128-bit vectors ? > > > > > > > > > > I think patterns common to both Neon and MVE should be moved to > > > vec-common.md, I don't know why such patterns were left in neon.md. > > Since we end up calling neon_expand_vector_init for both NEON and MVE, > > I am not sure if we should separate the pattern ? > > Would it make sense to FAIL if the mode size isn't 16 bytes for MVE as > > in attached patch so > > it will call neon_expand_vector_init only for 128-bit vectors ? > > Altho hard-coding 16 in the pattern doesn't seem a good idea to me either. > ping https://gcc.gnu.org/pipermail/gcc-patches/2021-June/572342.html > (attaching patch as text). ping https://gcc.gnu.org/pipermail/gcc-patches/2021-June/572648.html Thanks, Prathamesh > > Thanks, > Prathamesh > > > > Thanks, > > Prathamesh > > > > > > That being said, I suggest you look at other similar patterns in > > > vec-common.md, most of which are gated on > > > ARM_HAVE__ARITH > > > and possibly beware of issues with iwmmxt :-) > > > > > > Christophe > > > > > > > Thanks, > > > > Prathamesh