From patchwork Fri Jan 27 08:44:35 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: 138197 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 414B6B6EF1 for ; Fri, 27 Jan 2012 19:44:47 +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=1328258691; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC: Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=fsfWWKb12OeW2fGXrTA5deCh0vU=; b=F2+xxpwNPzIARoydOQBtwdfpUDZBmTYRjnEnH86m7N/ESVWu08eex3uw5Bh3Jl auvteelkk69WSqCmVBX4tSCDsNcYjcp9Te+1VfwTDu3J+gw6OkHlZ6IVkpuP/Mjn Fyek97xgeuwiPOEwQEbf1ZKE+7G9GkszCg4iT4uWH6/I8= 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:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=e7oKdM1X9MWK8kG7rmCy9mK0ivP/T80/+z5RzlOBTiwyzHfjQg33h/BuO5XQMl 7bMwOzGuNV7cML8dh13HzjrG2u0txGXtGMaIxV24JwXkAigCJv20LQqOihr71sr/ rTdGIREAusgCoaA5DtMSaI5HJr+IFkBGOWnRovn6Z8z04=; Received: (qmail 18828 invoked by alias); 27 Jan 2012 08:44:42 -0000 Received: (qmail 18814 invoked by uid 22791); 27 Jan 2012 08:44:41 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 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; Fri, 27 Jan 2012 08:44:16 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1RqhPq-0005mR-FD from Tom_deVries@mentor.com ; Fri, 27 Jan 2012 00:44:14 -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); Fri, 27 Jan 2012 00:44:14 -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; Fri, 27 Jan 2012 08:44:12 +0000 Message-ID: <4F2263F3.80100@mentor.com> Date: Fri, 27 Jan 2012 09:44:35 +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: Re: [PATCH] FIx for PR51990 - ICE in copy_reference_ops_from_ref References: <4F211E6E.8030506@mentor.com> In-Reply-To: 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 On 26/01/12 12:08, Richard Guenther wrote: > On Thu, Jan 26, 2012 at 10:35 AM, Tom de Vries wrote: >> 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. > > The create_component_ref_by_pieces_1 handling is incorrect - you fail > to properly re-instantiate operand 1 (currop->op0). You should add > a new case for WITH_SIZE_EXPR and properly handle it via > > op0expr = get_or_alloc_expr_for (currop->op0); > genop0 = find_or_generate_expression (block, op0expr, > stmts, domstmt); > if (!genop0) > return NULL_TREE; > I see. Updated patch, bootstrapped and reg-tested on x86_64. Ok for stage4 or stage1? Thanks, - Tom > Richard. > 2012-01-27 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) @@ -2792,6 +2792,23 @@ create_component_ref_by_pieces_1 (basic_ return folded; } break; + case WITH_SIZE_EXPR: + { + tree genop0 = create_component_ref_by_pieces_1 (block, ref, operand, + stmts, domstmt); + pre_expr op1expr = get_or_alloc_expr_for (currop->op0); + tree genop1; + + if (!genop0) + return NULL_TREE; + + genop1 = find_or_generate_expression (block, op1expr, stmts, domstmt); + if (!genop1) + return NULL_TREE; + + return fold_build2 (currop->opcode, currop->type, genop0, genop1); + } + break; case BIT_FIELD_REF: { tree folded; 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; +}