From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20109 invoked by alias); 28 Mar 2008 19:19:38 -0000 Received: (qmail 19947 invoked by uid 48); 28 Mar 2008 19:18:55 -0000 Date: Fri, 28 Mar 2008 19:19:00 -0000 Message-ID: <20080328191855.19946.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/30911] VRP fails to eliminate range checks in Ada code In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-03/txt/msg02296.txt.bz2 ------- Comment #46 from rguenth at gcc dot gnu dot org 2008-03-28 19:18 ------- Ok, I didn't really expect that ;) Some new background information. With the middle-end type-system work we now omit conversions from sub-types T' to their base-types T. Thus we have the three cases T' sub; T x; x = sub; (1) sub = (T')x; (2) x = VIEW_CONVERT_EXPR (sub); (3) where VRP for the simple copy (1) does not restrict x value range based on the T's TYPE_MIN/MAX_VALUE (but it should). For (2) the same is true (though the conversion is _not_ truncating for out of bound values, so I am not sure if this doesn't break something). But for both (1) and (2) holds that a variable of type T' can be assumed to have a value range restricted by its TYPE_MIN/MAX_VALUE. Case (3) is special in that it is a propagation barrier, thus x will get a varying value range. We could do better here if we knew that subs value range was not restricted by its TYPE_MIN/MAX_VALUE only. I don't know if this is really the best setup to optimize Ada range checks, or if we should always fall back to the base types TYPE_MIN/MAX_VALUE range and use the type defined range of the sub-types T' only in special places like for example for the initial value-range of T' variables default definitions (thus uninitialized values and function parameters where if I understand correctly in Ada the caller ensures that the value is in range). Of course this wouldn't work very well in combination with inlining. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30911