From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 466133857400 for ; Fri, 29 Jul 2022 20:09:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 466133857400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-122-Y4LOdDEsOCWRuBA3wFnwgA-1; Fri, 29 Jul 2022 16:09:28 -0400 X-MC-Unique: Y4LOdDEsOCWRuBA3wFnwgA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A8DF8039B8; Fri, 29 Jul 2022 20:09:28 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57F792026985; Fri, 29 Jul 2022 20:09:27 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 26TK9OOK243348 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 22:09:25 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 26TK9NGb243347; Fri, 29 Jul 2022 22:09:23 +0200 Date: Fri, 29 Jul 2022 22:09:23 +0200 From: Jakub Jelinek To: Andrew Stubbs Cc: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH] openmp-simd-clone: Match shift type Message-ID: Reply-To: Jakub Jelinek References: <02ee1acd-1951-8cf9-345b-ca230ae432bb@codesourcery.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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 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: Fri, 29 Jul 2022 20:09:40 -0000 On Fri, Jul 29, 2022 at 06:03:18PM +0100, Andrew Stubbs wrote: > On 29/07/2022 16:59, Jakub Jelinek wrote: > > Doing the fold_convert seems to be a wasted effort to me. > > Can't this be done conditional on whether some change is needed at all > > and just using gimple_build_assign with NOP_EXPR, so something like: > > I'm just not familiar enough with this stuff to run fold_convert in my head > with confidence. The thing with fold_convert is that if some conversion is needed (and fold_convert actually is strict, so even if the conversion is useless but the type isn't exactly the same) it creates a NOP_EXPR around the argument, and then gimple_build_assign notices it should create a NOP_EXPR assign rhs op and just uses the argument of NOP_EXPR, where the NOP_EXPR will be GC later. Plus, if the conversion isn't needed, it creates an extra assignment that will be only later in some other pass optimized away. > > > tree shift_cvt_conv = shift_cnt; > > if (!useless_type_conversion_p (TREE_TYPE (mask), > > TREE_TYPE (shift_cnt))) > > { > > shift_cnt_conv = make_ssa_name (TREE_TYPE (mask)); > > g = gimple_build_assign (shift_cnt_conv, NOP_EXPR, shift_cnt); > > gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING); > > } > > > > Your version gives the same output mine does, at least on amdgcn anyway. > > Am I OK to commit this version? Yes, thanks. > openmp-simd-clone: Match shift types > > Ensure that both parameters to vector shifts use the same mode. This is most > important for amdgcn where the masks are DImode. > > gcc/ChangeLog: > > * omp-simd-clone.cc (simd_clone_adjust): Convert shift_cnt to match > the mask type. > > Co-authored-by: Jakub Jelinek > > diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc > index 32649bc3f9a..58bd68b129b 100644 > --- a/gcc/omp-simd-clone.cc > +++ b/gcc/omp-simd-clone.cc > @@ -1305,8 +1305,16 @@ simd_clone_adjust (struct cgraph_node *node) > build_int_cst (TREE_TYPE (iter1), c)); > gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING); > } > + tree shift_cnt_conv = shift_cnt; > + if (!useless_type_conversion_p (TREE_TYPE (mask), > + TREE_TYPE (shift_cnt))) > + { > + shift_cnt_conv = make_ssa_name (TREE_TYPE (mask)); > + g = gimple_build_assign (shift_cnt_conv, NOP_EXPR, shift_cnt); > + gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING); > + } > g = gimple_build_assign (make_ssa_name (TREE_TYPE (mask)), > - RSHIFT_EXPR, mask, shift_cnt); > + RSHIFT_EXPR, mask, shift_cnt_conv); > gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING); > mask = gimple_assign_lhs (g); > g = gimple_build_assign (make_ssa_name (TREE_TYPE (mask)), Jakub