From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28921 invoked by alias); 15 Oct 2013 12:00:32 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 28882 invoked by uid 89); 15 Oct 2013 12:00:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f174.google.com Received: from mail-lb0-f174.google.com (HELO mail-lb0-f174.google.com) (209.85.217.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 15 Oct 2013 12:00:28 +0000 Received: by mail-lb0-f174.google.com with SMTP id w6so6679190lbh.19 for ; Tue, 15 Oct 2013 05:00:24 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.152.170.166 with SMTP id an6mr35396806lac.20.1381838424756; Tue, 15 Oct 2013 05:00:24 -0700 (PDT) Received: by 10.114.12.163 with HTTP; Tue, 15 Oct 2013 05:00:24 -0700 (PDT) In-Reply-To: References: Date: Tue, 15 Oct 2013 12:00:00 -0000 Message-ID: Subject: Re: programming language that does not inhibit further optimization by gcc From: Rob To: Albert Abramson Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2013-10/txt/msg00149.txt.bz2 GCC does value analysis similar to what you mentioned. You'll find it under the -fdump-tree-vrp options. To provide extra information you can add range checks which GCC will pick up on. If you know a value is small, use a small integer type and gcc will pick up the range of values which can be assigned to it. What are the problems you're trying to solve? Is it a low memory system you're running on? If you're after performance, add restrict to your parameters and either use unions to get around aliasing or do what the Linux dev team do with -fno-strict-aliasing. Regarding threading - I think trying to use multiple threads without having to learn thread libraries is a bit of a gamble. Threading is difficult even in high level languages and you should have a good background before approaching. For struct packing, I suppose you could just order your entries largest-first which is one approach, but it's kinda like the 0-1 knapsack problem. On 15 October 2013 01:31, Albert Abramson wrote: > I have been looking everywhere online and talking to other coders at > every opportunity about this, but cannot find a complete answer. > Different languages have different obstacles to complete optimization. > Software developers often have to drop down into non-portable > Assembly because they can't get the performance or small size of > hand-optimized Assembly for their particular platform. > > The C language has the alias issue that limits the hoisting of loads. > Unless the programmer specifies that two arrays will never overlap > using the 'restrict' keyword, the compiler may not be able to handle > operations on arrays efficiently because of the unlikely event that > the arrays could overlap. Most/all languages also demand the > appearance of serialization of instructions and memory operations, as > well as extreme correctness in even the most unlikely circumstances, > even where the programmer may not need them. > > Is there a language out there (similar to Fortran or a dialect of C) > that doesn't inhibit the compiler from taking advantage of every > optimization possible? Is there some way to provide a C/C++ compiler > with extra information about variables and programs so that it can > maximize performance or minimize size? For example: > > int age =3D 21; //[0, 150) setting maximum limits, compiler could use= byte int > int outsideTemp =3D 20; //[-273, 80] > float ERA =3D 297; //[0, 1000, 3] [min, max, digits of > accuracy needed] > > Better yet, allow some easier way of spawning multiple threads without > have to learn all of the Boost libraries, OpenCL, or OpenGL. In other > words, is there yet a language that is designed only for performance > that places no limits on compiler optimizations? Is there a language > that allows the compiler to pack struct variables in tighter by > reorganizing those values, etc? > > If not, is it possible to put together some dialect of C/C++ that > replaces Assembly outright? > > -- > Max Abramson > =93In the end, more than freedom, they wanted security. They wanted a > comfortable life, and they lost it all =96 security, comfort, and > freedom. When the Athenians finally wanted not to give to society but > for society to give to them, when the freedom they wished for most was > freedom from responsibility, then Athens ceased to be free and was > never free again.=94 --Sir Edward Gibbon