From patchwork Mon Nov 30 23:27:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 550562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1E7C41401B5 for ; Tue, 1 Dec 2015 10:27:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=KuG4K9FH; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=BNoIfAE5L7udLSs8rNXGRNjW5SLZeW7CrtU46mXvyMHiA7RXxP1Ik x4UAUsprXadCdJW8t52p6s0gYEtz/wXO9KBGD9lucg4ZNOi3FdkzqXQSsZKvM/eN GTO1axiIFC1b/4HtACe3S9TyRLzEQUhmPjEh/dpEtUoh7Gt2WCW0lY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=iVPC8+RfWku5dYebQxKlFGjoe8A=; b=KuG4K9FHyHdCctvudRqY KQxaf/Lo8rEkRHMpuLlKaKlBRBQ5YRvNqTqBA6D0sxUWxvbv3raD9rFvdrpZhed8 2EI8CmVVNetenAhDhwfhGngDPJEHrcaA9gQ4nSVa6MQUOBgkL/VZYFtzm+U8ZFWE +4cQRCUobhNEX0mrdv9gxqU= Received: (qmail 35601 invoked by alias); 30 Nov 2015 23:27:16 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 35590 invoked by uid 89); 30 Nov 2015 23:27:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_05, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 30 Nov 2015 23:27:14 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C2C70AC01 for ; Mon, 30 Nov 2015 23:27:11 +0000 (UTC) Date: Tue, 1 Dec 2015 00:27:11 +0100 From: Martin Jambor To: GCC Patches Subject: [hsa] Use gimplify_expr in gridification Message-ID: <20151130232711.GC19649@virgil.suse.cz> Mail-Followup-To: GCC Patches MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi, doing some more testing of the branch and combining two of my testcases I came accross a bug where temporaries created by force_gimple_operand_gsi were not added to the proper bind and thus were subsequently re-mapped to error_mark when the target construct was within some other omp construct. Fixed with this patch, where pop_gimplify_context does the right thing like at other places in omp-low.c. Committed to the branch. Thanks, Martin 2015-11-30 Martin Jambor * omp-low.c (attempt_target_gridification): Use gimplify_expr. --- gcc/omp-low.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index bdf6539..7fbdcdf 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -17481,6 +17481,7 @@ attempt_target_gridification (gomp_target *target, gimple_stmt_iterator *gsi, gpukernel); walk_tree (&group_size, remap_prebody_decls, &wi, NULL); + push_gimplify_context (); size_t collapse = gimple_omp_for_collapse (inner_loop); for (size_t i = 0; i < collapse; i++) { @@ -17499,30 +17500,32 @@ attempt_target_gridification (gomp_target *target, gimple_stmt_iterator *gsi, tree step; step = get_omp_for_step_from_incr (loc, gimple_omp_for_incr (inner_loop, i)); - n1 = force_gimple_operand_gsi (gsi, fold_convert (type, n1), true, - NULL_TREE, true, GSI_SAME_STMT); - n2 = force_gimple_operand_gsi (gsi, fold_convert (itype, n2), true, - NULL_TREE, - true, GSI_SAME_STMT); + gimple_seq tmpseq = NULL; + n1 = fold_convert (itype, n1); + n2 = fold_convert (itype, n2); tree t = build_int_cst (itype, (cond_code == LT_EXPR ? -1 : 1)); t = fold_build2 (PLUS_EXPR, itype, step, t); t = fold_build2 (PLUS_EXPR, itype, t, n2); - t = fold_build2 (MINUS_EXPR, itype, t, fold_convert (itype, n1)); + t = fold_build2 (MINUS_EXPR, itype, t, n1); if (TYPE_UNSIGNED (itype) && cond_code == GT_EXPR) t = fold_build2 (TRUNC_DIV_EXPR, itype, fold_build1 (NEGATE_EXPR, itype, t), fold_build1 (NEGATE_EXPR, itype, step)); else t = fold_build2 (TRUNC_DIV_EXPR, itype, t, step); - t = fold_convert (uint32_type_node, t); - tree gs = force_gimple_operand_gsi (gsi, t, true, NULL_TREE, true, - GSI_SAME_STMT); + tree gs = fold_convert (uint32_type_node, t); + gimplify_expr (&gs, &tmpseq, NULL, is_gimple_val, fb_rvalue); + if (!gimple_seq_empty_p (tmpseq)) + gsi_insert_seq_before (gsi, tmpseq, GSI_SAME_STMT); + tree ws; if (i == 0 && group_size) { ws = fold_convert (uint32_type_node, group_size); - ws = force_gimple_operand_gsi (gsi, ws, true, NULL_TREE, true, - GSI_SAME_STMT); + tmpseq = NULL; + gimplify_expr (&ws, &tmpseq, NULL, is_gimple_val, fb_rvalue); + if (!gimple_seq_empty_p (tmpseq)) + gsi_insert_seq_before (gsi, tmpseq, GSI_SAME_STMT); } else ws = build_zero_cst (uint32_type_node); @@ -17534,7 +17537,7 @@ attempt_target_gridification (gomp_target *target, gimple_stmt_iterator *gsi, OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (target); gimple_omp_target_set_clauses (target, c); } - + pop_gimplify_context (tgt_bind); delete declmap; return; }