From patchwork Wed Jun 12 17:54:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 1114745 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-502852-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="aaQrq8z3"; dkim-atps=neutral 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 45PDyb28lBz9sNT for ; Thu, 13 Jun 2019 03:54:15 +1000 (AEST) 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:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=SgcLLRthBPc1upQsZmreqsI+cJGeiKfJWlCPUS3KhWUXv/ZGnT zYVqQU3827cgCLhoqlkHHc4R3JJpLPJV9+RtdGnr1wphWkPaImXJkRzSGMInYMe3 LVlmNZbSZesAdT+rGrWVDUqUgcBKbfRuBTOQbceIZeNtH98TLZKuID+7s= 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:cc:subject:message-id:mime-version:content-type; s= default; bh=6CYpW3rfWNTBdKJh+EdkDSKcANI=; b=aaQrq8z3XQ6z5E3HtVRO i37BFthUjcuNseEPd+xqTOwZKQsEFKKTPUKqbt353CtmhlAZglJeAIloryXja4ak 2gJWPPcDcdJfulHgUxEGfPMHozGA5dGSJDF6zeuib8NjqnOPcQ1PnCOI1W/enFNy U0/eOzm4KOUYbwmh+AiaAUg= Received: (qmail 90069 invoked by alias); 12 Jun 2019 17:54:07 -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 90060 invoked by uid 89); 12 Jun 2019 17:54:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=bailing, fopenacc, HX-Languages-Length:2208 X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Jun 2019 17:54:05 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7A9C7AE6D; Wed, 12 Jun 2019 17:54:02 +0000 (UTC) Date: Wed, 12 Jun 2019 19:54:00 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Cc: Richard Biener , Thomas Schwinge Subject: [PATCH][openacc] Disable pass_thread_jumps for IFN_UNIQUE Message-ID: <20190612175359.GA32526@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi, If we compile the openacc testcase with -fopenacc -O2, we run into a SIGSEGV or assert. The root cause for this is that pass_thread_jumps breaks the invariant that OACC_FORK and OACC_JOIN mark the start and end of a single-entry-single-exit region. Fix this by bailing out when encountering an IFN_UNIQUE in thread_jumps::profitable_jump_thread_path. Bootstrapped and reg-tested on x86_64. Build and reg-tested libgomp on x86_64 with nvptx accelerator. OK for trunk? Thanks, - Tom [openacc] Disable pass_thread_jumps for IFN_UNIQUE 2019-06-12 Tom de Vries PR tree-optimization/90009 * tree-ssa-threadbackward.c (thread_jumps::profitable_jump_thread_path): Return NULL if bb contains IFN_UNIQUE. * testsuite/libgomp.oacc-c-c++-common/pr90009.c: New test. --- gcc/tree-ssa-threadbackward.c | 5 ++++ .../testsuite/libgomp.oacc-c-c++-common/pr90009.c | 34 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 81dc05dc831..1ff870ad00b 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -261,6 +261,11 @@ thread_jumps::profitable_jump_thread_path (basic_block bbi, tree name, gsi_next_nondebug (&gsi)) { gimple *stmt = gsi_stmt (gsi); + if (gimple_call_internal_p (stmt, IFN_UNIQUE)) + { + m_path.pop (); + return NULL; + } /* Do not count empty statements and labels. */ if (gimple_code (stmt) != GIMPLE_NOP && !(gimple_code (stmt) == GIMPLE_ASSIGN diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr90009.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr90009.c new file mode 100644 index 00000000000..58d1039dd8d --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr90009.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ + +#include + +#define N 100 + +int data[N]; + +int +main (void) +{ + int n = N, b = 3; +#pragma acc parallel num_workers(2) + { + int c; + if (n) + c = 0; + else + c = b; + +#pragma acc loop worker + for (int i = 0; i < n; i++) + data[i] = 1; + + if (c) + data[0] = 2; + } + + for (int i = 0; i < n; i++) + if (data[i] != 1) + abort (); + + return 0; +}