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.129.124]) by sourceware.org (Postfix) with ESMTPS id 75AA73858D33 for ; Fri, 20 Jan 2023 18:00:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75AA73858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674237628; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=aqAARqyJIvl25nip2RhjSpF3PKYWRAuheKkF9kP0Z6s=; b=HKxT3WnMH4KHrRmIWNxHYvLX5bwoVS4wa+q/Z7NCOrW8lZ6Civk68bIyJLb4jX/VoftUQa jNLyYciiAMc5XEaDKd57uPx5wtLy4Txy2Ug10zC/jzJxOUC+kyYIZyHiCvv4yEUz5BGdx9 Mm5Yvu0NQy2rLdcuVcNyvy1zJJcUenI= 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-275-omTz1_3SPyCJaqT1B72pPw-1; Fri, 20 Jan 2023 13:00:24 -0500 X-MC-Unique: omTz1_3SPyCJaqT1B72pPw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 339C818E0043; Fri, 20 Jan 2023 18:00:24 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6AA82166B2A; Fri, 20 Jan 2023 18:00:23 +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 30KI0JYG3389229 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 19:00:20 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30KI0IFx3389228; Fri, 20 Jan 2023 19:00:18 +0100 Date: Fri, 20 Jan 2023 19:00:18 +0100 From: Jakub Jelinek To: Tobias Burnus , gcc-patches , fortran Subject: Re: [Patch] OpenMP/Fortran: Partially fix non-rect loop nests [PR107424] Message-ID: Reply-To: Jakub Jelinek References: <18c3aed8-71dd-9b7f-6c7c-da529876d3f5@codesourcery.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: On Fri, Jan 20, 2023 at 06:39:04PM +0100, Jakub Jelinek via Gcc-patches wrote: > > + The issue is that for those a 'count' variable is used. */ > > + dovar_init *di; > > + unsigned ix; > > + tree t = tree_var; > > + while (TREE_CODE (t) == INDIRECT_REF) > > + t = TREE_OPERAND (t, 0); > > + FOR_EACH_VEC_ELT (*inits, ix, di) > > + { > > + tree t2 = di->var; > > + while (TREE_CODE (t2) == INDIRECT_REF) > > + t2 = TREE_OPERAND (t2, 0); > > The actual problem with non-simple loops for non-rectangular loops is > both in case it is an inner loop which uses some outer loop's iterator, > or if it is outer loop whose iterator is used, both of those cases > will not be handled properly. The former case because instead of > having lb and ub expressions in canonicalized form var-outer * m + a > lb will be 0 (that is fine) and ub will be > (var-outer * m2 + a2 + step - var-outer * m1 - a1) / step > or so (sure, we can simplify that to > (var-outer * (m1 - m2) + (a2 + step - a1)) / step > but the division remains. And the latter case is bad because we > need var-outer but we actually compute some artificial count iterator > and var-outer is only initialized in the body of the loop. > These sorry_at seems to handle just one of those, when the outer > loop whose var-outer is referenced is not simple, no? Though, I wonder if we shouldn't for GCC 13 just sorry_at about steps other than constant 1/-1 (in both outer loop with var-outer referenced in inner loop and on inner loop that references it) and for the !VAR_P case actually handle it if step 1/-1 by using simple like translation just with an artificial iterator. Say for: subroutine foo (x, y, z) integer :: x, y, z !$omp do private (x) do x = y, z end do end subroutine foo we right now in *.original dump have: D.4265 = *y; D.4266 = *z; D.4267 = (1 - D.4265) + D.4266; #pragma omp for private(count.0) private(x) for (count.0 = 0; count.0 < D.4267; count.0 = count.0 + 1) { *x = D.4265 + NON_LVALUE_EXPR ; L.1:; } What I'd suggest is: D.4265 = *y; D.4266 = *z; #pragma omp for private(x) for (x.0 = D.4265; x.0 <= D.4266; x.0 = x.0 + 1) { *x = x.0; L.1:; } or so. This could be done independently from the non-rect stuff, as a first change. Jakub