From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125651 invoked by alias); 4 Nov 2015 08:51:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 125639 invoked by uid 89); 4 Nov 2015 08:51:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 04 Nov 2015 08:51:00 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 749FB2A71FF0; Wed, 4 Nov 2015 09:50:57 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZtfnUy2K9Z3e; Wed, 4 Nov 2015 09:50:57 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 2A8392A71FDC; Wed, 4 Nov 2015 09:50:57 +0100 (CET) From: Eric Botcazou To: Richard Biener Cc: gcc-patches@gcc.gnu.org, Jan Hubicka Subject: Re: Add VIEW_CONVERT_EXPR to operand_equal_p Date: Wed, 04 Nov 2015 08:51:00 -0000 Message-ID: <2270331.u4G6gq9JGs@polaris> User-Agent: KMail/4.14.9 (Linux/3.16.7-29-desktop; KDE/4.14.9; x86_64; ; ) In-Reply-To: References: <20151014162944.GE16672@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2204758.gJ83KI3YrQ" Content-Transfer-Encoding: 7Bit X-SW-Source: 2015-11/txt/msg00300.txt.bz2 This is a multi-part message in MIME format. --nextPart2204758.gJ83KI3YrQ Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Content-length: 2697 > Ah - tree_ssa_useless_type_conversion and callers, during gimplification. > I'd like to get rid of it but maybe simply delete the VIEW_CONVERT_EXPR > case from it for now (and return true unconditionally for NON_LVALUE_EXPR). > > Index: gcc/tree-ssa.c > =================================================================== > --- gcc/tree-ssa.c (revision 229517) > +++ gcc/tree-ssa.c (working copy) > @@ -1142,13 +1161,16 @@ delete_tree_ssa (struct function *fn) > bool > tree_ssa_useless_type_conversion (tree expr) > { > + /* Not strictly a conversion but this function is used to strip > + useless stuff from trees returned from GENERIC folding. */ > + if (TREE_CODE (expr) == NON_LVALUE_EXPR) > + return true; > + > /* If we have an assignment that merely uses a NOP_EXPR to change > the top of the RHS to the type of the LHS and the type conversion > is "safe", then strip away the type conversion so that we can > enter LHS = RHS into the const_and_copies table. */ > - if (CONVERT_EXPR_P (expr) > - || TREE_CODE (expr) == VIEW_CONVERT_EXPR > - || TREE_CODE (expr) == NON_LVALUE_EXPR) > + if (CONVERT_EXPR_P (expr)) > return useless_type_conversion_p > (TREE_TYPE (expr), > TREE_TYPE (TREE_OPERAND (expr, 0))); The patch introduces GIMPLE checking failures: FAIL: c52103m FAIL: c52103r FAIL: c52104m FAIL: c52104r of the form: slice9.adb: In function 'Slice9': slice9.adb:1:1: error: conversion of an SSA_NAME on the left hand side VIEW_CONVERT_EXPR("ABCDE"); D.4379 = &VIEW_CONVERT_EXPR("ABCDE")[D.4378 ...] {lb: D.4195 sz: 1}; if (TREE_CODE (expr) == VIEW_CONVERT_EXPR) { /* For VIEW_CONVERT_EXPRs which are allowed here too, we only check that their operand is not an SSA name or an invariant when requiring an lvalue (this usually means there is a SRA or IPA-SRA bug). Otherwise there is nothing to verify, gross mismatches at most invoke undefined behavior. */ if (require_lvalue && (TREE_CODE (op) == SSA_NAME || is_gimple_min_invariant (op))) { error ("conversion of an SSA_NAME on the left hand side"); debug_generic_stmt (expr); return true; } else if (TREE_CODE (op) == SSA_NAME && TYPE_SIZE (TREE_TYPE (expr)) != TYPE_SIZE (TREE_TYPE (op))) { error ("conversion of register to a different size"); debug_generic_stmt (expr); return true; } else if (!handled_component_p (op)) return false; } It's related to dynamic slicing (reduced testcase attached). * gnat.dg/slice9.adb: New test. -- Eric Botcazou --nextPart2204758.gJ83KI3YrQ Content-Disposition: attachment; filename="slice9.adb" Content-Transfer-Encoding: 7Bit Content-Type: text/x-adasrc; charset="UTF-8"; name="slice9.adb" Content-length: 297 -- { dg-do compile } procedure Slice9 is function Ident (I : Integer) return Integer is begin return I; end; subtype S is String (Ident(5)..Ident(9)); Dest : S; Src : String (Ident(1)..Ident(5)) := "ABCDE"; begin Dest (Ident(5)..Ident(7)) := Src (Ident(1)..Ident(3)); end; --nextPart2204758.gJ83KI3YrQ--