From patchwork Thu Jan 26 09:35:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 137897 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 B6243B6F98 for ; Thu, 26 Jan 2012 20:35:45 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1328175346; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC: Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=R25+6sQn5Gk8yto7bMeRtaPSF+4=; b=d9STQTbyC3kvkwt ADcTguLk3QwZMjJDIGeYD0wqCZGsk5g2aSCEiTTdSyJek/mtndZON+fLGUJzt58S 287FLIxE+2yKxzDO76ArTnLg84nfCno1U1f7vAMDO2p0Ane0xu54xrAZGwQZvsuV RWoGdTyBjlJIyDDO8Vl0t8vDCOMw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ZqbP2W493nAHeMAKOKSWi7IM4a8MRxB9iquTL5rAmsJNvMkw6sHck3wm5/YiJW rlFrq1jSHEQg3iA94Q5ueTkIdHjAcXbXVgMADp6GjP5lmSiJ6aJAsSzozOyLL8Uj rbKNiZ6o02c42mK4Il+qfgspIomTELjhSu8gU0oszwCWo=; Received: (qmail 18026 invoked by alias); 26 Jan 2012 09:35:42 -0000 Received: (qmail 17860 invoked by uid 22791); 26 Jan 2012 09:35:40 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, SUBJ_OBFU_PUNCT_FEW, SUBJ_OBFU_PUNCT_MANY X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 Jan 2012 09:35:27 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1RqLjp-0002Hv-Nf from Tom_deVries@mentor.com ; Thu, 26 Jan 2012 01:35:25 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 26 Jan 2012 01:35:25 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Thu, 26 Jan 2012 09:35:23 +0000 Message-ID: <4F211E6E.8030506@mentor.com> Date: Thu, 26 Jan 2012 10:35:42 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Lightning/1.0b2 Thunderbird/3.1.16 MIME-Version: 1.0 To: Richard Guenther CC: "gcc-patches@gcc.gnu.org" Subject: [PATCH] FIx for PR51990 - ICE in copy_reference_ops_from_ref 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 Richard, This patch fixes PR51990. The patch adds handling of WITH_SIZE_EXPR in copy_reference_ops_from_ref and create_component_ref_by_pieces_1, preventing ICEs on the test-cases. Bootstrapped and reg-tested on x86_64. Ok for stage4 or stage1? Thanks, - Tom 2012-01-26 Tom de Vries PR tree-optimization/51990 * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle WITH_SIZE_EXPR. * tree-ssa-pre.c (create_component_ref_by_pieces_1): Same. * gcc.dg/pr51990.c: New test. * gcc.dg/pr51990-2.c: Same. Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c (revision 183325) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -624,6 +624,10 @@ copy_reference_ops_from_ref (tree ref, V switch (temp.opcode) { + case WITH_SIZE_EXPR: + temp.op0 = TREE_OPERAND (ref, 1); + temp.off = 0; + break; case MEM_REF: /* The base address gets its own vn_reference_op_s structure. */ temp.op0 = TREE_OPERAND (ref, 1); @@ -740,6 +744,7 @@ copy_reference_ops_from_ref (tree ref, V VEC_safe_push (vn_reference_op_s, heap, *result, &temp); if (REFERENCE_CLASS_P (ref) + || TREE_CODE (ref) == WITH_SIZE_EXPR || (TREE_CODE (ref) == ADDR_EXPR && !is_gimple_min_invariant (ref))) ref = TREE_OPERAND (ref, 0); Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 183325) +++ gcc/tree-ssa-pre.c (working copy) @@ -2780,6 +2780,7 @@ create_component_ref_by_pieces_1 (basic_ case REALPART_EXPR: case IMAGPART_EXPR: case VIEW_CONVERT_EXPR: + case WITH_SIZE_EXPR: { tree folded; tree genop0 = create_component_ref_by_pieces_1 (block, ref, @@ -2787,8 +2788,12 @@ create_component_ref_by_pieces_1 (basic_ stmts, domstmt); if (!genop0) return NULL_TREE; - folded = fold_build1 (currop->opcode, currop->type, - genop0); + + folded + = (currop->opcode == WITH_SIZE_EXPR + ? fold_build2 (currop->opcode, currop->type, genop0, currop->op0) + : fold_build1 (currop->opcode, currop->type, genop0)); + return folded; } break; Index: gcc/testsuite/gcc.dg/pr51990.c =================================================================== --- /dev/null (new file) +++ gcc/testsuite/gcc.dg/pr51990.c (revision 0) @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +zzz (char *s1, char *s2, int len, int *q) +{ + int z = 5; + unsigned int i, b; + struct s { char a[z]; }; + struct s x; + + extern int foo (int, ...) __attribute__((pure)); + + for (i = 0; i < len; i++) + s1[i] = s2[i]; + + b = z & 0x3; + + len += (b == 0 ? 0 : 1) + z; + + *q = len; + return foo (z, x, x); +} Index: gcc/testsuite/gcc.dg/pr51990-2.c =================================================================== --- /dev/null (new file) +++ gcc/testsuite/gcc.dg/pr51990-2.c (revision 0) @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int y; +extern int foo (int, ...) __attribute__((pure)); + +int +zzz (char *s1, char *s2, int len, int *q, int c) +{ + int z = 5; + unsigned int i, b; + struct s { char a[z]; }; + struct s x; + int y_tmp = 5; + + for (i = 0; i < len; i++) + s1[i] = s2[i]; + + b = z & 0x3; + + len += (b == 0 ? 0 : 1) + z; + + *q = len; + + if (c) + y_tmp = foo (z, x, x) + 4; + + z = foo (z, x, x) + 4; + y = y_tmp; + + return z; +}