From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58236 invoked by alias); 3 Nov 2016 12:47:04 -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 58220 invoked by uid 89); 3 Nov 2016 12:47:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-wm0-f66.google.com Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Nov 2016 12:46:49 +0000 Received: by mail-wm0-f66.google.com with SMTP id u144so7871886wmu.0 for ; Thu, 03 Nov 2016 05:46:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=UUqQ64vVQrMcZ+q5umauGgut0zD7LX0EztJ6veumL+4=; b=TjaCQixm4jgp77XuZeTxxnWjuM+0b/fY9Nd9o8ZI2ARnHnk6hhi0CZbCIAq3FDFHn1 fTGcOzJdnYKnMUB3pQzByDt8D4P9JWoFBUN67fUCyHMGHE9wVS8jEILIM6tyEchneJRF x1mSWVbRTTG6N02GvZVn92bHUPBIqpDIvKA679EF4ALuwtEFqwxsUwJgWqeH4lpr4a/z n8MJaZIMWRl5zsp4YxZaoqvZaoN3ABHO226/atYFKU1+EwOi/vXD3vheVW0kEb6reuE2 siV6A8r6W5w6gl67WdjsJxF3SGalfLZhWvCLy/vLEmbsNtx2iuvOjsS18rtKh623ftm/ NpIg== X-Gm-Message-State: ABUngvfcGykeBRwrDW4CHZy9WaX7BuFqhPimioFIilHl1eTHtraroIcDeJrvAuX0PLKIGArX1cOKBwFiD4j9kg== X-Received: by 10.28.55.213 with SMTP id e204mr7844494wma.92.1478177206879; Thu, 03 Nov 2016 05:46:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.73.215 with HTTP; Thu, 3 Nov 2016 05:46:46 -0700 (PDT) In-Reply-To: <1a50afaa-6b8e-ba98-6cde-aae51c05a2c4@suse.cz> References: <1a50afaa-6b8e-ba98-6cde-aae51c05a2c4@suse.cz> From: Richard Biener Date: Thu, 03 Nov 2016 12:47:00 -0000 Message-ID: Subject: Re: [PATCH] Convert character arrays to string csts To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: GCC Patches , Jan Hubicka Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00295.txt.bz2 On Thu, Nov 3, 2016 at 1:12 PM, Martin Li=C5=A1ka wrote: > Hello. > > This is small follow-up of the patches I sent to string folding. > The patch transforms character array defined in an initializer to string > constant: > > +const char global[] =3D {'a', 'b', 'c', 'd', '\0'}; > > Apart from that, it also enables string folding of local symbols like: > + const char local[] =3D "abcd"; > > Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Hmm, does this handle const char global[] =3D {'a', [4] =3D 'd', 'b', [3] =3D '\0'}; correctly? I think you need to check that 'key' is increasing and there are no gaps (ISTR constructor elements are sorted but gaps can still appear). + || !useless_type_conversion_p (TREE_TYPE (value), char_type_node)) please instead check the element type of the array constructor. I'd also use a stricter check like TYPE_MAIN_VARIANT (type) =3D=3D char_type_node to avoid changing non-strings like unsigned / signed char. Finally I'm a bit worried about doing this for all 'char' constructors. Maybe we should restrict this to those with ISPRINT () entries? Richard. > Martin