From patchwork Wed Jul 31 11:21:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1967070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=Y8Bihghv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WYqSB44Hzz1ybV for ; Wed, 31 Jul 2024 21:22:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70DB9385B529 for ; Wed, 31 Jul 2024 11:22:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 53A103858C56 for ; Wed, 31 Jul 2024 11:21:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53A103858C56 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 53A103858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722424899; cv=none; b=oWSjsCXpAHAmdAgSJTVJ5AymiNQV9M6UxqZCoynU1NBaHsOyiqAaljGFrZffi/RW3/r4NAcamWHmWCq3TN6Z8zjpWeAxHGz0q23a68sPSImf4pHFJhGyRhbZARZwLVw4EWTUA9i2uiEv62Z1AEvTVtjulDQ7m6bjTlO0TrXrr4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722424899; c=relaxed/simple; bh=vLEdCHjaV91SZirBeZaAoaTFjGIaecNZE1azGGEh3K4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=pSAAcql5L7EyWfV6uUqdSa2wOKlC0t66YnynBpGyJtG3K/qx4HKcEm0kdD/x9Jnpz4ncdJfU06FoogKZJJmShmxxgVm3PkGcSk6MPBRhEONVhgUCH9tSA/DV+Lz13ZEbGGHCp5lVLmLVUid2f9/lcYPA4vOqNXjWy6dfM/QGdDI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3684e8220f9so425582f8f.1 for ; Wed, 31 Jul 2024 04:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722424896; x=1723029696; darn=gcc.gnu.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=GN8n06cdrlv8T8g0XI262x0HDl7uv5qlOVEq678y++4=; b=Y8Bihghve/TgUTTgZ5e+BgsoQhdlhJ7pv/ZTWC2NRuPeaNhZLAOj2pq4BsTV8ml2aN OtdYtxG5NCsd6SPVveTJat9tCiUfuJOs+BkVACAhcK/tjirM3MEJGhxRA8ULGPyT8jL6 ygSv88e/12lyRSNIqrxPXk/t9s7mCramT62ZbeTdQ3RZVEwlWaFzxSevmW8vb0MUlCc+ sOS6ODrCaKLikZerfzCUvyeqsJ5JJ2h7lmRFhPfiDH1sZK6BfMbyEwJE9ybNSvRLOm3/ TC63inJV95AXZdlrSffSzQozTKUE+c66MnF3qz5nluFONhygpN2RrY6yww8QyX/YFMBy yrSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424896; x=1723029696; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=GN8n06cdrlv8T8g0XI262x0HDl7uv5qlOVEq678y++4=; b=CcHdgApBeSR6rRvzQUKcwmP5mo+IInM/Hvi7CSiL2nOlfhUgvKiRpvihC/ZGHjx4eA YIZ6rP/d8odeapCBfLbPlbN/7HyNLD+x2983E+v8rF7+MKbBQ49lJzJHUDDjhxB6yDRz XTGkk866M4/IHLPK6oQF5Bs6eZ/9E84k9XCt2FR/5m8KhnhlS/DJ1IQqkrMwSYD/nnrg uahcmnXyQXOcmkltMGnncxIkbyvIvDaOjkCOrpmM8bCiUbcgL9nMmkjoeHb7aljVeQH5 cP5cp8WytCCEqLMagJ3190TVVW/KHiIfr9S51IxS4vx2z9ty3uLI+l7fknqg+IBcdPTi PEkQ== X-Gm-Message-State: AOJu0YyFpB/oskEDcfiLByPwUedjWCc7NhSjSTBBdB7g/Q7Q9W0MqN7j 9krZauPOQuIC8v7gehHye6Rdj8u6+5BjwRMco9XoxUd2rvBBg+rrba+WH2D6yEk= X-Google-Smtp-Source: AGHT+IGDyUL0DgglHAgkbhK8PirsC9a1eYY1Qx/DaBJoq1uiOKDahyHLDrNu8g3Hy/t4e/kGvfXweA== X-Received: by 2002:a05:6000:1866:b0:367:9048:e952 with SMTP id ffacd0b85a97d-36b8c8e9a0amr4250517f8f.18.1722424895596; Wed, 31 Jul 2024 04:21:35 -0700 (PDT) Received: from ?IPV6:2001:16b8:3d2b:2600:379e:fd4e:ac25:ba19? ([2001:16b8:3d2b:2600:379e:fd4e:ac25:ba19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4282bb9d54esm17898145e9.43.2024.07.31.04.21.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 31 Jul 2024 04:21:35 -0700 (PDT) Message-ID: <0973962b-900d-48d5-92fa-44964f99d3ce@baylibre.com> Date: Wed, 31 Jul 2024 13:21:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [Patch, v3] omp-offload.cc: Fix value-expr handling of 'declare target link' vars [PR115637] (was: [Patch] gimplify.cc: Handle VALUE_EXPR of MEM_REF's ADDR_EXPR argument [PR115637]) To: Richard Biener , Jakub Jelinek Cc: gcc-patches References: Content-Language: en-US From: Tobias Burnus In-Reply-To: X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HTML_MESSAGE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi Richard, hi all, Richard Biener wrote: > Looking at pass_omp_target_link::execute I wonder iff find_link_var_op > shouldn't simply do the substitution? Aka This seems to work ... > --- a/gcc/omp-offload.cc > +++ b/gcc/omp-offload.cc > @@ -2893,6 +2893,7 @@ find_link_var_op (tree *tp, int *walk_subtrees, void *) > && is_global_var (t) > && lookup_attribute ("omp declare target link", DECL_ATTRIBUTES (t))) > { > + *tp = unshare_expr (DECL_VALUE_EXPR (t)); > *walk_subtrees = 0; > return t; > } > > which then makes the stmt obviously not gimple? ... except that 'return t' prevents updating other value-expr in the same stmt, but that can be fixed. Updated patch attached. Thanks for the suggestion! Tobias omp-offload.cc: Fix value-expr handling of 'declare target link' vars As the PR and included testcase shows, replacing 'arr2' by its value expression '*arr2$13$linkptr' failed for MEM [(c_char * {ref-all})&arr2] which left 'arr2' in the code as unknown symbol. Now expand the value expression already in pass_omp_target_link::execute's process_link_var_op walk_gimple_stmt walk - and don't rely on gimple_regimplify_operands. PR middle-end/115637 gcc/ChangeLog: * gimplify.cc (gimplify_body): Fix macro name in the comment. * omp-offload.cc (found_link_var): New global var. (find_link_var_op): Rename to ... (process_link_var_op): ... this. Replace value expr; set found_link_var. (pass_omp_target_link::execute): Update walk_gimple_stmt call. libgomp/ChangeLog: * testsuite/libgomp.fortran/declare-target-link.f90: Uncomment now working code. Co-authored-by: Richard Biener PR115637 - ! if (res /= -11436) stop 5 - if (res /= -11546) stop 5 ! FIXME + ! print *, res + if (res /= -11436) stop 5 end integer function run_device1() !$omp declare target integer :: i run_device1 = -99 - ! FIXME: arr2 not link mapped -> PR115637 - ! arr2 = [11,22,33,44] + arr2 = [11,22,33,44] if (any (arr(10:50) /= [(i, i=10,50)])) then run_device1 = arr(11) return end if - ! FIXME: -> PR115637 - ! run_device1 = sum(arr(10:13) + arr2) - run_device1 = sum(arr(10:13) ) ! FIXME + run_device1 = sum(arr(10:13) + arr2) do i = 10, 50 arr(i) = 3 - 10 * arr(i) end do