From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id AF1063858D35 for ; Mon, 31 Oct 2022 21:41:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AF1063858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102c.google.com with SMTP id f5-20020a17090a4a8500b002131bb59d61so192038pjh.1 for ; Mon, 31 Oct 2022 14:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=AXm/kxzN1F1JcQSI41Se2ug/8DtTXAb1ZbPf5GA+CZU=; b=QOLKreFJzd0IdQ499qd+owqqxeq1GPD2YF/Ug9hcFkmOsBrOcbDS9jx+54blk1QhvM opHqNRUm5+z/yPciAJX8e9cVRCaTuHN65ViS29batB2hlODh8jWneO9ucoKz4ZPzh0O7 s4TA/M38pA4gCH2DOV/wcV7qvnVUJmMs7WzR/GcjVJWWWU5U/cCEUAp/dlEjgsgJIuqV NEkCuFl13SCg4FH4I4DkXz8Ri+gC9oKt30WA5nKoHIH/hdd1zd7LEAGJTYR+hPCkIb4h 3t7GaZU1bM0pV6+WzJGJNjkZpfM59r5vYWXqreHOJc2z7cqq94Q0MJgEFJWyECt3TAav v5eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AXm/kxzN1F1JcQSI41Se2ug/8DtTXAb1ZbPf5GA+CZU=; b=STe6TG2opZFK75474VzzA4eWkdAyXvjfTqxW89pO0ddiUaGB7/FS86PFE/t8tr4K/J +SqvuAiBYSORSSYjYwt0GFHAxVf0IQ/1w676iVgmnr2L4tnbs1mDxKLZBi/r2IC/Nstx DCopq08+6OiJyZgNZVpMdcsPSatz0Z8ztgWLBFcf/Q71w2N0BkeQgOjdxmITkESUuUNA /x3l0mVSjUZsDmSZM+F0thUTpkfQMgi9lr/kDIRY7Jw+6hx1QJ7n0y9F+MxULFHEb9Dz ESTspZ2tIsgyT7nYkBUQ0WIJ7QJgn9OgJsURpMo1Qty0N2zdBtPpAQfZnZt9H1kOt9du jpQA== X-Gm-Message-State: ACrzQf3plNkXjBTq1yjyBUGT4y171ka00ZfYJJSxO7LQzPc5drpt8ugc WTJR1cnWSk6CFG7xkBALbJw= X-Google-Smtp-Source: AMsMyM55m3r5iAs+bJsA77ob0gPTTpq3hxcc4uMLGrwIU5qy6fkpiJe+Ex5lBguwHy0p8Jzp9ZRHYg== X-Received: by 2002:a17:902:c412:b0:186:a279:717f with SMTP id k18-20020a170902c41200b00186a279717fmr16330336plk.29.1667252475565; Mon, 31 Oct 2022 14:41:15 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id s2-20020a63ff42000000b00439f027789asm4601588pgk.59.2022.10.31.14.41.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Oct 2022 14:41:15 -0700 (PDT) Message-ID: <1bc972d0-1f3f-7d8e-16f1-33a77b2644b0@gmail.com> Date: Mon, 31 Oct 2022 15:41:13 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH 1/8]middle-end: Recognize scalar reductions from bitfields and array_refs Content-Language: en-US To: Tamar Christina , gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de References: From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,NICE_REPLY_A,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 10/31/22 05:56, Tamar Christina wrote: > Hi All, > > This patch series is to add recognition of pairwise operations (reductions) > in match.pd such that we can benefit from them even at -O1 when the vectorizer > isn't enabled. > > Ths use of these allow for a lot simpler codegen in AArch64 and allows us to > avoid quite a lot of codegen warts. > > As an example a simple: > > typedef float v4sf __attribute__((vector_size (16))); > > float > foo3 (v4sf x) > { > return x[1] + x[2]; > } > > currently generates: > > foo3: > dup s1, v0.s[1] > dup s0, v0.s[2] > fadd s0, s1, s0 > ret > > while with this patch series now generates: > > foo3: > ext v0.16b, v0.16b, v0.16b, #4 > faddp s0, v0.2s > ret > > This patch will not perform the operation if the source is not a gimple > register and leaves memory sources to the vectorizer as it's able to deal > correctly with clobbers. > > The use of these instruction makes a significant difference in codegen quality > for AArch64 and Arm. > > NOTE: The last entry in the series contains tests for all of the previous > patches as it's a bit of an all or nothing thing. > > Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu > and no issues. > > Ok for master? > > Thanks, > Tamar > > gcc/ChangeLog: > > * match.pd (adjacent_data_access_p): Import. > Add new pattern for bitwise plus, min, max, fmax, fmin. > * tree-cfg.cc (verify_gimple_call): Allow function arguments in IFNs. > * tree.cc (adjacent_data_access_p): New. > * tree.h (adjacent_data_access_p): New. Nice stuff.  I'd pondered some similar stuff at Tachyum, but got dragged away before it could be implemented. > diff --git a/gcc/tree.cc b/gcc/tree.cc > index 007c9325b17076f474e6681c49966c59cf6b91c7..5315af38a1ead89ca5f75dc4b19de9841e29d311 100644 > --- a/gcc/tree.cc > +++ b/gcc/tree.cc > @@ -10457,6 +10457,90 @@ bitmask_inv_cst_vector_p (tree t) > return builder.build (); > } > > +/* Returns base address if the two operands represent adjacent access of data > + such that a pairwise operation can be used. OP1 must be a lower subpart > + than OP2. If POS is not NULL then on return if a value is returned POS > + will indicate the position of the lower address. If COMMUTATIVE_P then > + the operation is also tried by flipping op1 and op2. */ > + > +tree adjacent_data_access_p (tree op1, tree op2, poly_uint64 *pos, > + bool commutative_p) Formatting nit.  Return type on a different line. OK with that fixed. jeff