From patchwork Sun Jul 16 18:59:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 789109 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 3x9bMM4GChz9t2M for ; Mon, 17 Jul 2017 04:59:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="JTAxbJWh"; 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 :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=OD9PKfOXlxeT0Ofkr aTjXl1Yut8znrKkAQijWjQ4CBSI9wmJxxsDVX3R0YBNePtWBHqVSWRzge7bjkfLT u01+1hWxD8WcHyYIzZn8vItgFy90G0XAXXMYqflGG8dkXZ8Izt1gr3XJLKPWkUA7 6X+CFUVcdhFirQwba0+q0Iq13U= 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 :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=MKpe/mZM3iFnCEcScR0cb1O pzQI=; b=JTAxbJWhqUA+UI/ybdMsZMfBuPuSI+iG5NkZZppC9zixlK499sNfmI6 32atT4VFho/SndGvqzunDs8x0tSQiS8sfgbCkcMuapt5dZTjwmmofWN08Usbk3Jp ww1d4Dx9JijW3Oybfe3hX8tt+zrx8mI1DEoOuQJGuKIP4rRLdGMs= Received: (qmail 60818 invoked by alias); 16 Jul 2017 18:59:33 -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 60801 invoked by uid 89); 16 Jul 2017 18:59:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=spending, HTo:U*thomas, cure 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; Sun, 16 Jul 2017 18:59:29 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1dWolK-00059l-P9 from Tom_deVries@mentor.com for gcc-patches@gcc.gnu.org; Sun, 16 Jul 2017 11:59:26 -0700 Received: from [127.0.0.1] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Sun, 16 Jul 2017 19:59:21 +0100 Subject: [gomp4, nvptx, committed] Fix --enable-checking=rtl assert in nvptx_propagate_unified To: Thomas Schwinge , GCC Patches References: <43470dd6-1f0b-7602-703a-60c8543c74e3@mentor.com> <8760f6rq6v.fsf@hertz.schwinge.homeip.net> From: Tom de Vries Message-ID: <1c63678b-8d00-febb-a494-84dfb206bcdd@mentor.com> Date: Sun, 16 Jul 2017 20:59:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <8760f6rq6v.fsf@hertz.schwinge.homeip.net> X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) [ was: Re: [gomp4, nvptx, committed] Fix assert in nvptx_propagate_unified ] On 07/06/2017 09:15 AM, Thomas Schwinge wrote: > 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... > Hi, I see, thanks for letting me know. Hmm, it looks like the build and test config with which I ran into this problem only has the default checking (All my private build and test configs use yes,rtl). >> 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? Correct, AFAICT nvptx_propagate_unified is something that was not ported to trunk yet. > 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? > I took most of your patch, but used next_real_insn to skip over the note. Tested on x86_64 with nvptx accelerator. Committed to gomp-4_0-branch. Thanks, - Tom Fix --enable-checking=rtl assert in nvptx_propagate_unified 2017-07-16 Tom de Vries * config/nvptx/nvptx.c (nvptx_propagate_unified): Use next_real_insn to find comparison insn. Assert that comparison is found. --- gcc/config/nvptx/nvptx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 69b5740..32420c3 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -2294,22 +2294,25 @@ 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 checking.) */ for (;;) { - probe = NEXT_INSN (probe); + probe = next_real_insn (probe); + if (!probe) + break; 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); rtx pred_reg = SET_DEST (pat); /* Find the branch. */