From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 3201838582B5 for ; Mon, 24 Oct 2022 08:12:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3201838582B5 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-il1-x12b.google.com with SMTP id g13so4854367ile.0 for ; Mon, 24 Oct 2022 01:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=8Xg8Q50ofjxZK06fq7ALl55TjXLT1xRMq0mSdh47e8A=; b=UNRmEKTFgbnL8xM1KILM6qmGzh2DwAg41wx4P80mT9mF5eNJGPuWGwSZ2HD8/4u3SA 3gf0FWhhoy6UOuQoEaQdC/EVwgY+/lGC/tZwJAJodFRL+ope3jHywU5lGgvTU2qdhplP 3ny8r6mKc9O613U/UTpGzqV4R+HxOdtCTwTwIN9yplnhDblx9oFvc8l7p0cmJcvHuMu2 Jg5MM1AvkMaYgyZbTwL/4ZsZejxaKLUt7LfK0ZyhbKVxyNqL22C5Lcr6jrlG04Fn0bOI ZSc8L26szSBSPh203iYHnM0kg2LDawRzYwKQ8JlI8hwIL2l/KHn+XUmwJLPi0hbCUVUA 29rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8Xg8Q50ofjxZK06fq7ALl55TjXLT1xRMq0mSdh47e8A=; b=cnXiqTLDgYBN3K1pKehfD1CXtJuq7/twmoXd2LnIGJXv43Toc9vchz3BnKGTz6yhW0 aJZcRefM0G+Na6QPnAeKCaDhrHlc1miLSspb70cIx9thjW+FvQrRVTo/VeuKcro0FHpv N/jhhcMh14ubDUi4b0xrOI8aRijSnn/pAsG54sOzpczT8W2gBqBQf31xvUyLm3+s7X0w RV+OdlQgiaxOLNhB6ElErmb3GKhLKE3STkjQFqyFlDIOqe8trmlbo+xbUEwRSyqwxL+s GGdc9QkOHEauhPRpEr/vNNA9UhhT4Rj7oOoBGC1rQLzHh9jvooh3OGKCCCJ3NGSAWBOP 2kGQ== X-Gm-Message-State: ACrzQf2Tz3OZ44aQ9JpUGQr6TJfblwkdWqlECozM4tCsdRLO6GVBlARX k0XCydL2irdQxFtl/bgWPpSUNGvc73RahV9yVkHxvw== X-Google-Smtp-Source: AMsMyM73NLQIJXxAtFxUoPCpx8WmUlgys8FxJsVYcA6jkMIXZp/ttG02Msw/80vM77Bm3gSXei2gOFVjPB694+zd8Xg= X-Received: by 2002:a05:6e02:1b82:b0:2fa:f88f:7434 with SMTP id h2-20020a056e021b8200b002faf88f7434mr21276804ili.191.1666599158348; Mon, 24 Oct 2022 01:12:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Prathamesh Kulkarni Date: Mon, 24 Oct 2022 13:42:02 +0530 Message-ID: Subject: Re: Extend fold_vec_perm to fold VEC_PERM_EXPR in VLA manner To: Prathamesh Kulkarni , gcc Patches , Richard Biener , richard.sandiford@arm.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.6 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 17 Oct 2022 at 16:02, Prathamesh Kulkarni wrote: > > On Mon, 10 Oct 2022 at 16:18, Prathamesh Kulkarni > wrote: > > > > On Fri, 30 Sept 2022 at 21:38, Richard Sandiford > > wrote: > > > > > > Richard Sandiford via Gcc-patches writes: > > > > Prathamesh Kulkarni writes: > > > >> Sorry to ask a silly question but in which case shall we select 2nd vector ? > > > >> For num_poly_int_coeffs == 2, > > > >> a1 /trunc n1 == (a1 + 0x) / (n1.coeffs[0] + n1.coeffs[1]*x) > > > >> If a1/trunc n1 succeeds, > > > >> 0 / n1.coeffs[1] == a1/n1.coeffs[0] == 0. > > > >> So, a1 has to be < n1.coeffs[0] ? > > > > > > > > Remember that a1 is itself a poly_int. It's not necessarily a constant. > > > > > > > > E.g. the TRN1 .D instruction maps to a VEC_PERM_EXPR with the selector: > > > > > > > > { 0, 2 + 2x, 1, 4 + 2x, 2, 6 + 2x, ... } > > > > > > Sorry, should have been: > > > > > > { 0, 2 + 2x, 2, 4 + 2x, 4, 6 + 2x, ... } > > Hi Richard, > > Thanks for the clarifications, and sorry for late reply. > > I have attached POC patch that tries to implement the above approach. > > Passes bootstrap+test on x86_64-linux-gnu and aarch64-linux-gnu for VLS vectors. > > > > For VLA vectors, I have only done limited testing so far. > > It seems to pass couple of tests written in the patch for > > nelts_per_pattern == 3, > > and folds the following svld1rq test: > > int32x4_t v = {1, 2, 3, 4}; > > return svld1rq_s32 (svptrue_b8 (), &v[0]) > > into: > > return {1, 2, 3, 4, ...}; > > I will try to bootstrap+test it on SVE machine to test further for VLA folding. > With the attached patch it seems to pass bootstrap+test with SVE enabled. > The only difference w.r.t previous patch is it adds check in > get_vector_for_pattern > if S is constant otherwise returns NULL_TREE. > > I added this check because 930325-1.c ICE'd with previous patch > because it had following vec_perm_expr, > where S was non-constant: > vect__16.13_70 = VEC_PERM_EXPR POLY_INT_CST [3, 4], POLY_INT_CST [6, 8], POLY_INT_CST [9, 12], ... > }>; > I am not sure how to proceed in this case, so chose to bail out. Hi Richard, ping https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603717.html Thanks, Prathamesh > > Thanks, > Prathamesh > > > > > I have a couple of questions: > > 1] When mask selects elements from same vector but from different patterns: > > For eg: > > arg0 = {1, 11, 2, 12, 3, 13, ...}, > > arg1 = {21, 31, 22, 32, 23, 33, ...}, > > mask = {0, 0, 0, 1, 0, 2, ... }, > > All have npatterns = 2, nelts_per_pattern = 3. > > > > With above mask, > > Pattern {0, ...} selects arg0[0], ie {1, ...} > > Pattern {0, 1, 2, ...} selects arg0[0], arg0[1], arg0[2], ie {1, 11, 2, ...} > > While arg0[0] and arg0[2] belong to same pattern, arg0[1] belongs to different > > pattern in arg0. > > The result is: > > res = {1, 1, 1, 11, 1, 2, ...} > > In this case, res's 2nd pattern {1, 11, 2, ...} is encoded with: > > with a0 = 1, a1 = 11, S = -9. > > Is that expected tho ? It seems to create a new encoding which > > wasn't present in the input vector. For instance, the next elem in > > sequence would be -7, > > which is not present originally in arg0. > > I suppose it's fine since if the user defines mask to have pattern {0, > > 1, 2, ...} > > they intended result to have pattern with above encoding. > > Just wanted to confirm if this is correct ? > > > > 2] Could you please suggest a test-case for S < 0 ? > > I am not able to come up with one :/ > > > > Thanks, > > Prathamesh > > > > > > > which is an interleaving of the two patterns: > > > > > > > > { 0, 2, 4, ... } a0 = 0, a1 = 2, S = 2 > > > > { 2 + 2x, 4 + 2x, 6 + 2x } a0 = 2 + 2x, a1 = 4 + 2x, S = 2