From patchwork Thu Jul 10 18:43:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cesar Philippidis X-Patchwork-Id: 368742 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 2C98E140108 for ; Fri, 11 Jul 2014 04:43:27 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=c+el4q9P7B2kD00PcPMWaxOvfDFIXoEjrjb57qCUUgH7RD DQF9ot2R2VldVxli851UNFjf2w36W8QJq6mCM6Uv8cqAc9oLL3YlxwykZ9a8CdEH 3H1j9IOpzEhpgWgdEBiq6rHjk55tpoIzzVO0fXC9eKERNoX9++22rTTXyOdB8= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=3vduCCo49GzO436J2o39X2j92wY=; b=LFMY/49dCGyH+1Cle3SV EqyQDT2j2HZHH9DMqBBM62g5dPw+hP+8rlqT6UVDwqlgys5owpAVLDK1vmRLaPjv nQXPu9ASqMFbaFr4wjyfHHQDnVMx2ptoTRib27hiEvSCpBmdGbuC4xe4IX1ZqFa9 K413xymLBSgiDPL+D8OSw94= Received: (qmail 29534 invoked by alias); 10 Jul 2014 18:43:20 -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 29520 invoked by uid 89); 10 Jul 2014 18:43:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, FROM_12LTRDOM autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Jul 2014 18:43:16 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1X5JJI-0005GC-Sg from Cesar_Philippidis@mentor.com for gcc-patches@gcc.gnu.org; Thu, 10 Jul 2014 11:43:12 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 10 Jul 2014 11:43:12 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Thu, 10 Jul 2014 11:42:45 -0700 Message-ID: <53BEDEBF.7020106@codesourcery.com> Date: Thu, 10 Jul 2014 11:43:11 -0700 From: Cesar Philippidis User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Thomas Schwinge , "gcc-patches@gcc.gnu.org" Subject: [patch,gomp-4_0-branch] misc reduction clause bug fixes Hi Thomas, This patch addresses two bugs openacc reduction clause bugs. The first bug occurred because I didn't anticipate a GIMPLE_BIND stmt to be passed to process_reduction_data. Turns out, this could happen with the collapse clause. That's because the variables which were declared inside the inner loops need to be declared outside of the collapsed loop nest. The second issue is that process_reduction_clause adds unnecessary code if a reduction clause isn't present. The patch prevents that from happening. Is this OK for gomp-4_0-branch? I didn't include any test cases, because these bugs were exposed by the collapse clause patch. Thanks, Cesar diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 227ff1b..eb078b6 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -9679,11 +9679,23 @@ process_reduction_data (gimple_seq *body, gimple_seq *in_stmt_seqp, gcc_assert (is_gimple_omp_oacc_specifically (ctx->stmt)); gimple_stmt_iterator gsi; + gimple_seq inner; + gimple stmt; + + /* A collapse clause may have inserted a new bind block. */ + stmt = gimple_seq_first (*body); + if (stmt && gimple_code (stmt) == GIMPLE_BIND) + { + inner = gimple_bind_body (gimple_seq_first (*body)); + body = &inner; + } for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); tree call; + tree clauses, nthreads, t, c; + bool reduction_found = false; switch (gimple_code (stmt)) { @@ -9691,6 +9703,18 @@ process_reduction_data (gimple_seq *body, gimple_seq *in_stmt_seqp, tree clauses, nthreads, t; clauses = gimple_omp_for_clauses (stmt); + + /* Search for a reduction clause. */ + for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION) + { + reduction_found = true; + break; + } + + if (!reduction_found) + break; + ctx = maybe_lookup_ctx (stmt); t = NULL_TREE; @@ -9698,8 +9722,6 @@ process_reduction_data (gimple_seq *body, gimple_seq *in_stmt_seqp, Scan for the innermost vector_length clause. */ for (omp_context *oc = ctx; oc; oc = oc->outer) { - tree c; - switch (gimple_code (oc->stmt)) { case GIMPLE_OACC_PARALLEL: