From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120448 invoked by alias); 18 Aug 2015 17:51:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 120435 invoked by uid 89); 18 Aug 2015 17:51:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=BAYES_40,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f44.google.com Received: from mail-qg0-f44.google.com (HELO mail-qg0-f44.google.com) (209.85.192.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 18 Aug 2015 17:50:59 +0000 Received: by qgeb6 with SMTP id b6so4667178qge.3 for ; Tue, 18 Aug 2015 10:50:57 -0700 (PDT) X-Received: by 10.140.235.129 with SMTP id g123mr15755322qhc.11.1439920257509; Tue, 18 Aug 2015 10:50:57 -0700 (PDT) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id s25sm4020395qki.26.2015.08.18.10.50.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2015 10:50:56 -0700 (PDT) To: GCC Patches Cc: Cesar Philippidis From: Nathan Sidwell Subject: [gomp4] oacc xform tweak Message-ID: <55D37080.6010907@acm.org> Date: Tue, 18 Aug 2015 17:57:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000400060503040901030101" X-SW-Source: 2015-08/txt/msg01015.txt.bz2 This is a multi-part message in MIME format. --------------000400060503040901030101 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 478 I've committed this to gomp4 branch. It changes the oacc_xform_on_device and oacc_xform_dim_pos calls to lose the GSI parameter. Thus they look similar to the interface we're implementing for the reduction transformations. The iterator in the caller is advanced before the call, so it isn't left holding a potentially deleted instruction. I noticed a missing break which would have caused us to fall into the fork/join handling from the lock/unlock handling. nathan --------------000400060503040901030101 Content-Type: text/x-patch; name="gomp4-oacc-xform-dim.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gomp4-oacc-xform-dim.patch" Content-length: 2920 2015-08-18 Nathan Sidwell * omp-low.c (oacc_xform_on_device): Lose GSI parameter & adjust. (oacc_xform_dim): Likewise. (execute_oacc_transform): Adjust calls to oacc_xform_on_device and oacc_xform_dim. Insert breaks. Index: omp-low.c =================================================================== --- omp-low.c (revision 226978) +++ omp-low.c (working copy) @@ -14599,7 +14601,7 @@ make_pass_late_lower_omp (gcc::context * offloaded function we're never 'none'. */ static void -oacc_xform_on_device (gimple_stmt_iterator *gsi, gimple stmt) +oacc_xform_on_device (gimple stmt) { tree arg = gimple_call_arg (stmt, 0); unsigned val = GOMP_DEVICE_HOST; @@ -14624,15 +14626,16 @@ oacc_xform_on_device (gimple_stmt_iterat push_gimplify_context (true); gimplify_assign (lhs, result, &replace); pop_gimplify_context (NULL); - gsi_replace_with_seq (gsi, replace, false); + + gimple_stmt_iterator gsi = gsi_for_stmt (stmt); + gsi_replace (&gsi, replace, false); } /* Transform oacc_dim_size and oacc_dim_pos internal function calls to constants, where possible. */ static void -oacc_xform_dim (gimple_stmt_iterator *gsi, gimple stmt, - const int dims[], bool is_pos) +oacc_xform_dim (gimple stmt, const int dims[], bool is_pos) { tree arg = gimple_call_arg (stmt, 0); unsigned axis = (unsigned)TREE_INT_CST_LOW (arg); @@ -14654,7 +14657,9 @@ oacc_xform_dim (gimple_stmt_iterator *gs tree lhs = gimple_call_lhs (stmt); gimple g = gimple_build_assign (lhs, build_int_cst (integer_type_node, size)); - gsi_replace (gsi, g, false); + + gimple_stmt_iterator gsi = gsi_for_stmt (stmt); + gsi_replace (&gsi, g, false); } /* Main entry point for oacc transformations which run on the device @@ -14733,7 +14738,11 @@ execute_oacc_transform () else if (gimple_call_builtin_p (stmt, BUILT_IN_ACC_ON_DEVICE)) /* acc_on_device must be evaluated at compile time for constant arguments. */ - oacc_xform_on_device (&gsi, stmt); + { + gsi_next (&gsi); + oacc_xform_on_device (stmt); + continue; + } else if (gimple_call_internal_p (stmt)) { unsigned ifn_code = gimple_call_internal_fn (stmt); @@ -14743,15 +14752,16 @@ execute_oacc_transform () case IFN_GOACC_DIM_POS: case IFN_GOACC_DIM_SIZE: - oacc_xform_dim (&gsi, stmt, dims, - ifn_code == IFN_GOACC_DIM_POS); - break; + gsi_next (&gsi); + oacc_xform_dim (stmt, dims, ifn_code == IFN_GOACC_DIM_POS); + continue; case IFN_GOACC_LOCK: case IFN_GOACC_UNLOCK: if (targetm.goacc.lock_unlock (stmt, dims, ifn_code == IFN_GOACC_LOCK)) goto remove; + break; case IFN_GOACC_FORK: case IFN_GOACC_JOIN: @@ -14765,6 +14775,7 @@ execute_oacc_transform () /* Removal will have advanced the iterator. */ continue; } + break; } } gsi_next (&gsi); --------------000400060503040901030101--