From patchwork Wed May 11 18:26:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 95201 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]) by ozlabs.org (Postfix) with SMTP id 672B5100DEC for ; Thu, 12 May 2011 08:27:00 +1000 (EST) Received: (qmail 14423 invoked by alias); 11 May 2011 18:26:57 -0000 Received: (qmail 14409 invoked by uid 22791); 11 May 2011 18:26:57 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 May 2011 18:26:36 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4BIQaRx027916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 11 May 2011 14:26:36 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4BIQZtt017827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 11 May 2011 14:26:35 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p4BIQYxh023479 for ; Wed, 11 May 2011 20:26:34 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p4BIQYkT023477 for gcc-patches@gcc.gnu.org; Wed, 11 May 2011 20:26:34 +0200 Date: Wed, 11 May 2011 20:26:34 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE in use_narrower_mode (PR debug/48967) Message-ID: <20110511182633.GF17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! My http://gcc.gnu.org/ml/gcc-patches/2010-03/msg01379.html debug info optimization (meant primarily for x86_64) as the following testcase shows unfortunately breaks on powerpc64-linux and can in theory everywhere where lowpart_subreg of some REG accepted by use_narrower_mode_test isn't valid and thus returns NULL. This patch fixes it by not optimizing if the SUBREG isn't valid. Bootstrapped/regtested on x86_64-linux and i686-linux (where it never hits though) and on the testcase on powerpc64-linux. Ok for trunk/4.6? 2011-05-11 Jakub Jelinek PR debug/48967 * var-tracking.c (use_narrower_mode_test) : Return 1 if validate_subreg fails. * g++.dg/opt/pr48967.C: New test. Jakub --- gcc/var-tracking.c.jj 2011-05-11 19:39:04.000000000 +0200 +++ gcc/var-tracking.c 2011-05-11 19:51:48.000000000 +0200 @@ -745,6 +745,10 @@ use_narrower_mode_test (rtx *loc, void * case REG: if (cselib_lookup (*loc, GET_MODE (SUBREG_REG (subreg)), 0, VOIDmode)) return 1; + if (!validate_subreg (GET_MODE (subreg), GET_MODE (*loc), + *loc, subreg_lowpart_offset (GET_MODE (subreg), + GET_MODE (*loc)))) + return 1; return -1; case PLUS: case MINUS: --- gcc/testsuite/g++.dg/opt/pr48967.C.jj 2011-05-11 19:52:56.000000000 +0200 +++ gcc/testsuite/g++.dg/opt/pr48967.C 2011-05-11 19:52:27.000000000 +0200 @@ -0,0 +1,98 @@ +// PR debug/48967 +// { dg-do compile } +// { dg-options "-g -O2" } + +template struct A; +template struct A +{ + typedef T ref; +}; +template struct B +{ + typedef A t; + typedef typename t::ref ref; + ref operator * () { return ref (); } +}; +template struct I +{ + typedef T *cp; + template struct J + { + typedef I other; + }; +}; +template struct S : public I +{ +}; +template struct E +{ + typedef typename _A::template J ::other at; +}; +template > struct D +{ + typedef E _Base; + typedef typename _Base::at at; + typedef typename at::cp cp; + typedef B H; +}; +template struct F +{ + T *operator -> () { return __null; } +}; +template long +lfloor (T x) +{ + return static_cast (x) - (x && x != static_cast (x)); +} +template long +lround (T x) +{ + return lfloor (x - 0.5) + 1; +} +class M; +template class P; +typedef P Q; +template struct P +{ + float x (); +}; +struct CV +{ + Q c; +}; +struct C +{ + void foo (const CV &) const; + class O; + typedef D > R; + R n; +}; +struct S3 +{ + S3 (int, int); +}; +struct S2 +{ + S3 sx, sy; + S2 (int x = 0, int y = 0, int s = 0, int t = 0) : sx (x, y), sy (s, t) {} +}; +template struct N +{ + int bar (); +}; +struct C::O +{ + N o; + void foo (CV r, int) + { + Q c = r.c; + float t = 0.5 * (o.bar ()); + S2 (lround (c.x ()), t); + } +}; +void +C::foo (const CV &w) const +{ + R::H m; + (*m)->foo (w, 8); +}