From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8562 invoked by alias); 1 Mar 2008 13:19:53 -0000 Received: (qmail 8523 invoked by uid 22791); 1 Mar 2008 13:19:52 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 01 Mar 2008 13:19:34 +0000 Received: (qmail 18321 invoked from network); 1 Mar 2008 13:19:32 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 Mar 2008 13:19:32 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.68) (envelope-from ) id 1JVRch-0006cR-L6; Sat, 01 Mar 2008 13:19:31 +0000 Date: Sat, 01 Mar 2008 13:19:00 -0000 From: "Joseph S. Myers" To: Robert Dewar cc: Richard Kenner , Mark Mitchell , gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org, rguenther@suse.de Subject: Re: [PATCH][4.3] Deprecate -ftrapv In-Reply-To: <47C8C060.70503@adacore.com> Message-ID: References: <47C89DB1.6030200@codesourcery.com> <10803010013.AA29088@vlsi1.ultra.nyu.edu> <47C8B9D4.1000906@adacore.com> <47C8C060.70503@adacore.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 X-SW-Source: 2008-03/txt/msg00035.txt.bz2 On Fri, 29 Feb 2008, Robert Dewar wrote: > > If it were done at gimplification time I imagine something like the libgcc > > code would be used, but with conversions to/from unsigned inserted as > > needed. It would be possible to do optimizations at gimplification time if > > one argument is constant (converting to a range check). > > Well presumably one would want to use target dependent stuff for > detecting overflow where it exists (sticky overflow bits on > power, O flag on PC, trapping add on MIPS etc). On the whole I think you'd want to benefit from tree-ssa optimizing overflow checks where possible (including optimizing them away with VRP), if you hope for a -ftrapv that could be turned on by default for Ada with performance impact as small as possible. That would suggest back ends matching overflow-check patterns (including any that might have been written manually in the user's code) and converting them into such instructions. (Or expand or a late tree-ssa pass doing so.) But you could choose to use built-in functions corresponding to the present libgcc functions to represent overflow-checking operations, rather than expanding inline, and you could make the choice of whether to do so target-dependent. (One possibility is also using such builtins at gimplification time and then optimizing them later in tree-ssa - for example, converting a built-in checked multiplication to a range check if other optimizers make one argument into a constant.) The only targets defining the v insn patterns at present appear to be alpha and pa. -- Joseph S. Myers joseph@codesourcery.com