From patchwork Sat Jun 4 02:25:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 630127 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 3rM4ZR5lBxz9t3l for ; Sat, 4 Jun 2016 12:25:50 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=MeCW5cBQ; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=pkRqmX1CWfmiKNCdHW3m0kjg1heXp5aMO9Mc0YMHnJZSOxSGlY /SueMGZzU7n9vH1EMb4WYNDhs/PjXodMTolNc0UHerrBH2fv0yMHju2XEVU4I5VY HEQZ2mLvR6oSEtwI8oV26qfSVlyB2tRYI1gybUDMEGg3NTleVZtivS7Q8= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=yWq6LnCrRee8QEj1iPtAWRii08U=; b=MeCW5cBQnbVjULEYm1B9 3IMu5WxEuaygGGHJoYRcGTPyQgdEgCoYC7P+EiGC+4q3AMmXHv8ZHR0r6c3LYNF4 r2X5b4yxz4cbJJTG5Y4KigG+XSIpMyvPGlex5sO95uW9+heHedwHCooWsDDIU+Hi 65ZXgaYCtAY5YJs4vd19J70= Received: (qmail 110681 invoked by alias); 4 Jun 2016 02:25:42 -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 110591 invoked by uid 89); 4 Jun 2016 02:25:27 -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_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=2016-06-04, fn2, H*r:10.1.1, Hx-languages-length:2991 X-HELO: mail-pf0-f181.google.com Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 04 Jun 2016 02:25:17 +0000 Received: by mail-pf0-f181.google.com with SMTP id g64so49126972pfb.2 for ; Fri, 03 Jun 2016 19:25:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=AwYE+lTP+2Wy+E4K/muVPoOlNU8+I7iGp4fKuLtCOic=; b=AjtJnzLQqmFmNIFdFl4rxZh+MJcDnkCHV6vV5/ZAyGOreEJ3dIBdPW6MZkFfMSC/Ci BCoQBauNfngbEvIrF98lcABC8HkWCdqYCuNSz5fEvOrK7fVkZrwNla+FxqOGaNwpMA8J i3t+Iuslvc/PRope2C06DccmOG1AM2VsL4fTdBQrID7Ay6DDIRWC6nrnPKQPfJRnY1Vo Cdf2SV4eKRPXEK6tPAzbyZql6AutbZ958b7GBoMvbiODqJ0P8MRrA9Yjma1mHpf7l/+Q zE5o/BdH786Cv3vbyHvVZZZtFAtnFjZ9ZrrKwpJaEO0VTf8HelknpEhGJwJ6j/S+nNNZ znUg== X-Gm-Message-State: ALyK8tJK6/D9DRC/OoFrpHYngVTYtLm9UIePKOzaodfM83xj+c3uoTS/Wg8QAvaGIIDS0CmK X-Received: by 10.98.80.134 with SMTP id g6mr9716434pfj.87.1465007115210; Fri, 03 Jun 2016 19:25:15 -0700 (PDT) Received: from [10.1.1.13] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.gmail.com with ESMTPSA id p1sm11187788pfb.73.2016.06.03.19.25.12 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Jun 2016 19:25:13 -0700 (PDT) To: "gcc-patches@gcc.gnu.org" , Richard Biener From: kugan Subject: [PR71281] ICE on gcc trunk on knl, wsm, ivb and bdw targets Message-ID: <57523C01.5020808@linaro.org> Date: Sat, 4 Jun 2016 12:25:05 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, PR71281 happens when we use factored out negate stmt in other reassociations. Since we don't set the uid for this stmt, we hit the gcc_assert (in reassoc_stmt_dominates_stmt_p) which checks for uid being set. Attached patch fixes this. Regression tested on x86-64-linux-gnu with no new regression. Is this OK for trunk? Thanks, Kugan gcc/ChangeLog: 2016-06-04 Kugan Vivekanandarajah PR middle-end/71281 * tree-ssa-reassoc.c (reassociate_bb): Set uid for negate stmt. gcc/testsuite/ChangeLog: 2016-06-04 Kugan Vivekanandarajah PR middle-end/71281 * g++.dg/torture/pr71281.C: New test. diff --git a/gcc/testsuite/g++.dg/torture/pr71281.C b/gcc/testsuite/g++.dg/torture/pr71281.C index e69de29..7d429a9 100644 --- a/gcc/testsuite/g++.dg/torture/pr71281.C +++ b/gcc/testsuite/g++.dg/torture/pr71281.C @@ -0,0 +1,63 @@ +// PR middle-end/71281 +// { dg-do compile } +// { dg-additional-options "-std=c++11 -Ofast" } + + +template struct A; +template struct A<_Tp *> { typedef _Tp reference; }; + +template class B { +public: + typename A<_Iterator>::reference operator*(); +}; + +template class C; +template struct D; + +template struct D> { + using value_type = _Tp; + using const_pointer = _Tp *; + template using rebind_alloc = C<_Up>; +}; + +template struct __alloc_traits : D<_Alloc> { + typedef D<_Alloc> _Base_type; + typedef typename _Base_type::value_type &reference; + template struct F { + typedef typename _Base_type::template rebind_alloc<_Tp> other; + }; +}; + +template struct G { + typedef typename __alloc_traits<_Alloc>::template F<_Tp>::other + _Tp_alloc_type; +}; + +int a, b; +long d[1][1][1]; +void fn1() __attribute__((__noreturn__)); +template > class H { + typedef __alloc_traits::_Tp_alloc_type> _Alloc_traits; + typedef typename _Alloc_traits::reference reference; + +public: + B m_fn1(); + long m_fn2(); + reference operator[](unsigned); + reference m_fn3(unsigned){ + if (m_fn2()) + fn1(); + } +}; + +H>> c; +void fn2() { + H> e; + for (int f = 1;;) + for (int g = 0;;) + for (int h = 0;;) + { + *d[0][h] = + c.m_fn3(f)[0][g] * a + -*(e).m_fn1() * b + (*c[f].m_fn1()).m_fn3(g); + } +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 1973077..096b24d 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -5387,6 +5387,7 @@ reassociate_bb (basic_block bb) gimple_set_lhs (stmt, tmp); gassign *neg_stmt = gimple_build_assign (lhs, NEGATE_EXPR, tmp); + gimple_set_uid (neg_stmt, gimple_uid (stmt)); gimple_stmt_iterator gsi = gsi_for_stmt (stmt); gsi_insert_after (&gsi, neg_stmt, GSI_NEW_STMT); update_stmt (stmt);