From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id F2C3A3858D33 for ; Mon, 13 Feb 2023 06:29:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2C3A3858D33 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-wm1-x331.google.com with SMTP id bg5-20020a05600c3c8500b003e00c739ce4so8163815wmb.5 for ; Sun, 12 Feb 2023 22:29:21 -0800 (PST) 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=/BBC+hN0RGUSlChCblKpgqu4hwFGUDRTeB33iDedvzs=; b=EM0f5VUdbdGeIWip6H5TnNfVXFlNwe3CA2hhiVc/Em6zoistclPzFP3K30g4bS38Au XJEBDnUCXZkaPYnDIsSi6oabVTxqVTZZMMibLjEbGZCASweDxvtYqinN1jRcCquJf8vV Hk+Gn1dPdS29sKn/bpWO67O28BuRmx4+CmcaoDoo3t3OZ5Is7PxGxaI0kxf/YTFM2e0+ 22tyLlakzceZK0cAi1fz5amw7M0uDBtwH5ngQkjMu8Baq7QayQRIBWSd0uB5NOQTykyc 4scoAArCMLr/1kC2dnuR6ThXTg+9vzTVfI1EUeQQdKnRGSczjyxIyrHgnOGv2+eyANk7 oWpA== 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=/BBC+hN0RGUSlChCblKpgqu4hwFGUDRTeB33iDedvzs=; b=vpHK4Wkn7LMEzTTsVS7N4xCUwLdPmEZRdtpm2znd4xVvSpWNVE1IQnrLKbowt3l7ho 4eoxEX/7dSvqYZh+FxLSqGjJSc0duIlkcVaYT6f7hDsa2BQ8vHjVFGKLdN+bSzn+tPy+ 56me+B4xAgb/dG6RhUNsfEY3sooZB9TWibbZakdUnAeOO2ToVnh8RT/FWnXKeyUxPtn5 uIVn/Maz1CaFEdwl2+rm2t1Qje/zkN95S27UbD2wAgF8VdYfgKjAcZgB8fBanmlnmfgm kfI0CrfMwxQ6dyetUL4ZgkZ4SQBidr/s5Cz9qqkL9ipKybfSsQ0Lw4mof+188M2vRVY7 OMxw== X-Gm-Message-State: AO0yUKUg5UDw5vKxv93agwiVsB/Oq9vo4QizdpdbvLnYLYNqixg+PwPf POvOQHyt+ggTqgEnRNoMle9m0+Tktj9XcmX+Eiu1Papgmk1+hp6g X-Google-Smtp-Source: AK7set9WTjqrLK3cYfYwPyznRTmb/i0IPe77sIxGBu7Y9auDieE3tCu7rvkoZTOT3U/hiifY98gR9kmTNbaG4HH6YvY= X-Received: by 2002:a05:600c:4ecd:b0:3dc:b713:67ae with SMTP id g13-20020a05600c4ecd00b003dcb71367aemr794312wmq.68.1676269760153; Sun, 12 Feb 2023 22:29:20 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Prathamesh Kulkarni Date: Mon, 13 Feb 2023 11:58:43 +0530 Message-ID: Subject: Re: [aarch64] Code-gen for vector initialization involving constants To: gcc Patches , Richard Sandiford Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.5 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 Fri, 3 Feb 2023 at 12:46, Prathamesh Kulkarni wrote: > > Hi Richard, > While digging thru aarch64_expand_vector_init, I noticed it gives > priority to loading a constant first: > /* Initialise a vector which is part-variable. We want to first try > to build those lanes which are constant in the most efficient way we > can. */ > > which results in suboptimal code-gen for following case: > int16x8_t f_s16(int16_t x) > { > return (int16x8_t) { x, x, x, x, x, x, x, 1 }; > } > > code-gen trunk: > f_s16: > movi v0.8h, 0x1 > ins v0.h[0], w0 > ins v0.h[1], w0 > ins v0.h[2], w0 > ins v0.h[3], w0 > ins v0.h[4], w0 > ins v0.h[5], w0 > ins v0.h[6], w0 > ret > > The attached patch tweaks the following condition: > if (n_var == n_elts && n_elts <= 16) > { > ... > } > > to pass if maxv >= 80% of n_elts, with 80% being an > arbitrary "high enough" threshold. The intent is to dup > the most repeating variable if it it's repetition > is "high enough" and insert constants which should be "better" than > loading constant first and inserting variables like in the above case. > > Alternatively, I suppose we can remove threshold and for constants, > generate both sequences and check which one is more > efficient ? > > code-gen with patch: > f_s16: > dup v0.8h, w0 > movi v1.4h, 0x1 > ins v0.h[7], v1.h[0] > ret > > The patch is lightly tested to verify that vec[t]-init-*.c tests pass > with bootstrap+test > in progress. > Does this look OK ? Hi Richard, ping https://gcc.gnu.org/pipermail/gcc-patches/2023-February/611243.html Thanks, Prathamesh > > Thanks, > Prathamesh