From patchwork Fri Sep 10 09:45:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 64363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id CA44BB7111 for ; Fri, 10 Sep 2010 19:45:50 +1000 (EST) Received: (qmail 12145 invoked by alias); 10 Sep 2010 09:45:49 -0000 Received: (qmail 12137 invoked by uid 22791); 10 Sep 2010 09:45:48 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Sep 2010 09:45:44 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 4CAAFCB0246; Fri, 10 Sep 2010 11:45:42 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L49bt7qTV8HE; Fri, 10 Sep 2010 11:45:42 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 39AF6CB01E0; Fri, 10 Sep 2010 11:45:42 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 19595D9BB4; Fri, 10 Sep 2010 11:45:42 +0200 (CEST) Date: Fri, 10 Sep 2010 11:45:42 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Validity checks on boolean expressions Message-ID: <20100910094542.GA30175@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The value of a boolean expression or short-circuit operation is valid if the elementary operands of the expression are valid. This patch removes validity checks that were superfluous, and led to a quadratic expansion in the generated code for short-circuit expressions with multiple alternatives. No simple example available. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-09-10 Ed Schonberg * checks.adb (Ensure_Valid): If the expression is a boolean expression or short-circuit operation, do no emit a validity check: only the elementary operands of the expression need checking. Index: checks.adb =================================================================== --- checks.adb (revision 164098) +++ checks.adb (working copy) @@ -4108,6 +4108,17 @@ package body Checks is end if; end if; + -- If this is a boolean expression, only its elementary consituents + -- need checking: if they are valid, a boolean or short-circuit + -- operation with them will be valid as well. + + if Base_Type (Typ) = Standard_Boolean + and then + (Nkind (Expr) in N_Op or else Nkind (Expr) in N_Short_Circuit) + then + return; + end if; + -- If we fall through, a validity check is required Insert_Valid_Check (Expr);