From patchwork Thu Jul 6 07:15:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 784988 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 3x38Dy3hVyz9s72 for ; Thu, 6 Jul 2017 17:16:49 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="yg86eQy/"; 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:from :to:subject:in-reply-to:references:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=ktc 8dDWa38HjJyBz9XPNfPVKMZ0pYTBglHyYfcs7qmP18DlSVBY5qen58k+0Lz8IQnX Fry11wmPH3vAVIOya4rOMpOXyCnfyKg+ctyfrMdmTMJzZHMkqid2NTTrJhQ5/eK+ jj6Pr3aQr1fdkv8zbevnkUoPfKStblht4k06PtBw= 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:from :to:subject:in-reply-to:references:date:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=5+WbxzbX3 HlOt8dUxaufhonBIpQ=; b=yg86eQy/FcjSR/+Jj6rk5j/5jHia39pcnHvxyktsF 3p61kfteFsxpdPU1Tg64i7EXUvbP6rA8bZq78oEppfPhQNM6Zg1jJhtaGoJgHwAT nJtqQqrkxRpC0uDh/PAdyIl/PdGJC4MEU0AgW3OWO6lRrMtdN1IH6nI32pkRvFwf lw= Received: (qmail 19795 invoked by alias); 6 Jul 2017 07:16:26 -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 19407 invoked by uid 89); 6 Jul 2017 07:16:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=spending, cure, deemed 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, 06 Jul 2017 07:16:07 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1dT114-0000ET-Qz from Thomas_Schwinge@mentor.com for gcc-patches@gcc.gnu.org; Thu, 06 Jul 2017 00:15:59 -0700 Received: from hertz.schwinge.homeip.net (137.202.0.87) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Thu, 6 Jul 2017 08:15:55 +0100 From: Thomas Schwinge To: Tom de Vries , GCC Patches Subject: Re: [gomp4, nvptx, committed] Fix assert in nvptx_propagate_unified In-Reply-To: References: <43470dd6-1f0b-7602-703a-60c8543c74e3@mentor.com> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Thu, 6 Jul 2017 09:15:52 +0200 Message-ID: <8760f6rq6v.fsf@hertz.schwinge.homeip.net> MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) Hi Tom! On Fri, 30 Jun 2017 17:15:24 +0200, Tom de Vries wrote: > with the openacc test-case in attached patch, I ran into an assert here: Using your test case, in my build with "--enable-checking=yes,df,fold,rtl", I already earlier run into an ICE... > static void > nvptx_propagate_unified (rtx_insn *unified) > { > rtx_insn *probe = unified; > rtx cond_reg = SET_DEST (PATTERN (unified)); > rtx pat; > > /* Find the comparison. (We could skip this and simply scan to he > blocks' terminating branch, if we didn't care for self > checking.) */ > for (;;) > { > probe = NEXT_INSN (probe); > pat = PATTERN (probe); ... here: [...]/libgomp/testsuite/libgomp.oacc-c/../libgomp.oacc-c-c++-common/reduction-cplx-flt-2.c:19:9: internal compiler error: RTL check: expected elt 3 type 'e' or 'u', have '0' (rtx note) in PATTERN, at rtl.h:1440 Breakpoint 2, internal_error (gmsgid=0x10cc840 "RTL check: expected elt %d type '%c' or '%c', have '%c' (rtx %s) in %s, at %s:%d") at [...]/gcc/diagnostic.c:1251 1251 { (gdb) bt #0 internal_error (gmsgid=0x10cc840 "RTL check: expected elt %d type '%c' or '%c', have '%c' (rtx %s) in %s, at %s:%d") at [...]/gcc/diagnostic.c:1251 #1 0x00000000009bd2c7 in rtl_check_failed_type2 (r=0x7ffff688cd40, n=, c1=, c2=, file=, line=, func=0x106ac48 <_ZZ7PATTERNP7rtx_defE12__FUNCTION__> "PATTERN") at [...]/gcc/rtl.c:802 #2 0x0000000000529ef3 in PATTERN (insn=) at [...]/gcc/rtl.h:1440 #3 0x00000000005e5a2b in PATTERN (insn=) at [...]/gcc/rtl.h:1440 #4 0x0000000000d08b96 in nvptx_propagate_unified (unified=0x7ffff688ccc0) at [...]/gcc/config/nvptx/nvptx.c:2299 #5 0x0000000000d093e7 in nvptx_split_blocks (map=map@entry=0x7fffffffcc40) at [...]/gcc/config/nvptx/nvptx.c:2428 #6 0x0000000000d0d08b in nvptx_reorg () at [...]/gcc/config/nvptx/nvptx.c:3840 #7 0x00000000009bb0ea in (anonymous namespace)::pass_machine_reorg::execute (this=) at [...]/gcc/reorg.c:3952 [...] (gdb) frame 4 #4 0x0000000000d08b96 in nvptx_propagate_unified (unified=0x7ffff688ccc0) at [...]/gcc/config/nvptx/nvptx.c:2299 2299 pat = PATTERN (probe); (gdb) print probe $1 = (rtx_insn *) 0x7ffff688cd40 (gdb) call debug_rtx(probe) (note 56 54 57 3 NOTE_INSN_DELETED) > > if (GET_CODE (pat) == SET > && GET_RTX_CLASS (GET_CODE (SET_SRC (pat))) == RTX_COMPARE > && XEXP (SET_SRC (pat), 0) == cond_reg) > break; > gcc_assert (NONJUMP_INSN_P (probe)); > } > ... > > The assert happens when processing insn 56: > ... > (insn 54 53 56 3 (set (reg:SI 47 [ _71 ]) > (unspec:SI [ > (reg:SI 36 [ _58 ]) > ] UNSPEC_BR_UNIFIED)) 108 {cond_uni} > (nil)) > (note 56 54 57 3 NOTE_INSN_DELETED) > (insn 57 56 58 3 (set (reg:BI 68) > (gt:BI (reg:SI 47 [ _71 ]) > (const_int 1 [0x1]))) 99 {*cmpsi} > (expr_list:REG_DEAD (reg:SI 47 [ _71 ]) > (nil))) > ... > The insn 56 was originally a '(set (reg x) (const_int 1))', but that one > has been combined into insn 57 and replaced with a 'NOTE_INSN_DELETED'. > So it seems reasonable for the loop to skip over this note. > > Fixed by making the assert condition less strict. > > Build on x86_64 with nvptx accelerator. > > Tested test-case included in the patch. > > Committed as trivial. > --- a/gcc/config/nvptx/nvptx.c > +++ b/gcc/config/nvptx/nvptx.c > @@ -2300,7 +2300,7 @@ nvptx_propagate_unified (rtx_insn *unified) > && GET_RTX_CLASS (GET_CODE (SET_SRC (pat))) == RTX_COMPARE > && XEXP (SET_SRC (pat), 0) == cond_reg) > break; > - gcc_assert (NONJUMP_INSN_P (probe)); > + gcc_assert (NONJUMP_INSN_P (probe) || !INSN_P (probe)); > } > rtx pred_reg = SET_DEST (pat); These problems (both yours and mine) do not reproduce on trunk, right? But I suppose these are still a latent, just waiting for a different test case? Maybe this is a case to write an RTL-level test case? (Unless the fix is deemed trivial enough to warrent spending time on this.) Anyway, I don't know a lot about RTL, but the following patch does cure this test case (now running other testing). Would you please check that, and also whether nvptx_propagate_unified then still works as expected? Is this patch OK (both for gomp-4_0-branch, and also for trunk?), or should this rather use something like: -if (!INSN_P (probe)) +if (NOTE_P (probe) && NOTE_KIND (probe) == NOTE_INSN_DELETED) continue; ..., or something yet different? Grüße Thomas --- gcc/config/nvptx/nvptx.c +++ gcc/config/nvptx/nvptx.c @@ -2286,7 +2286,7 @@ nvptx_propagate_unified (rtx_insn *unified) { rtx_insn *probe = unified; rtx cond_reg = SET_DEST (PATTERN (unified)); - rtx pat; + rtx pat = NULL_RTX; /* Find the comparison. (We could skip this and simply scan to he blocks' terminating branch, if we didn't care for self @@ -2294,14 +2294,17 @@ nvptx_propagate_unified (rtx_insn *unified) for (;;) { probe = NEXT_INSN (probe); + if (!INSN_P (probe)) + continue; pat = PATTERN (probe); if (GET_CODE (pat) == SET && GET_RTX_CLASS (GET_CODE (SET_SRC (pat))) == RTX_COMPARE && XEXP (SET_SRC (pat), 0) == cond_reg) break; - gcc_assert (NONJUMP_INSN_P (probe) || !INSN_P (probe)); + gcc_assert (NONJUMP_INSN_P (probe)); } + gcc_assert (pat != NULL_RTX); rtx pred_reg = SET_DEST (pat); /* Find the branch. */