From patchwork Tue Mar 1 00:07:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 590254 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BC397140BA5 for ; Tue, 1 Mar 2016 11:07:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Ft8tQF6v; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=eW1Dog4p++q8Lx+9k5Sb/oDZUQ7c0v5XWKkxGuOEL1pAJWJ/G+ Y4kHOIsQkFKkZmATezv1z2jcFHzC2T6ksE55ckPkcKjTRWnhjEBQ3FrYImZvoElY mTLQ4FEzYhiGyczZU8REkbM2RGku98+xo7vewdZbfo9IZel47P7Uk2mhM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=xwQVD2RCF8FGRA+RDoBLE/yG748=; b=Ft8tQF6vtrTQNVCEnv0a 8NSzLB6zjyAHJgh0Xfr9jBgXkcpHFivcCvMFSGGQfY4yCAf/veEgWIi6hqYrtVlA K31ZIqVnn8FAqgeIXlUsLxIUGHGNvyck6TW0pcKpR9torOimIfmiy4n+yWZnWNih Bx8+ofhMwFbWY+LV0y0wtfU= Received: (qmail 97048 invoked by alias); 1 Mar 2016 00:07:37 -0000 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 Received: (qmail 97033 invoked by uid 89); 1 Mar 2016 00:07:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=integer_zerop, 957, Mar, mar X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 01 Mar 2016 00:07:35 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 7C7AA7F086 for ; Tue, 1 Mar 2016 00:07:34 +0000 (UTC) Received: from slagheap.utah.redhat.com (ovpn-113-135.phx2.redhat.com [10.3.113.135]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2107Yef012549 for ; Mon, 29 Feb 2016 19:07:34 -0500 To: "gcc-patches@gcc.gnu.org >> gcc-patches" From: Jeff Law Subject: [PATCH][PR tree-optimization/70005] Fix uncprop's handling of boolean ranged objects compared to non-boolean values Message-ID: <56D4DD40.7070206@redhat.com> Date: Mon, 29 Feb 2016 17:07:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 X-IsSubscribed: yes This mirrors a fix that was made to DOM a while back. Essentially we've got a test of a boolean ranged object against a value outside the range of a boolean. That's not correctly handled by uncprop at the moment, and is fixed by this patch. There's clearly a missed optimization there (and I'll file a separate bug for that). But even so, uncprop should handle that case gracefully. Bootstrapped and regression tested on x86-64-linux-gnu. Installed on the trunk. Jeff commit e1c1832e8e5d338b1b4357be0dcf98cadeda9b2e Author: law Date: Tue Mar 1 00:04:48 2016 +0000 PR tree-optimization/70005 * tree-ssa-uncprop.c (associate_equivalences_with_edges): Handle case where an object with a boolean range is compared against a value outside [0..1]. PR tree-optimization/70005 * gcc.c-torture/execute/pr70005.c New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233829 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 653b51e..ccbcfe8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2016-02-28 Jeff Law + PR tree-optimization/70005 + * tree-ssa-uncprop.c (associate_equivalences_with_edges): Handle case + where an object with a boolean range is compared against a value + outside [0..1]. + PR tree-optimization/69999 * gimple-ssa-split-paths.c (split_paths): When duplicating a block with an outgoing edge marked with EDGE_IRREDUCIBLE_LOOP, schedule diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 49577ee..3743d34 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-02-29 Jeff Law + PR tree-optimization/70005 + * gcc.c-torture/execute/pr70005.c New test. + PR tree-optimization/69999 * gcc.c-torture/compile/pr69999.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr70005.c b/gcc/testsuite/gcc.c-torture/execute/pr70005.c new file mode 100644 index 0000000..bc37efe --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr70005.c @@ -0,0 +1,25 @@ + +unsigned char a = 6; +int b, c; + +static void +fn1 () +{ + int i = a > 1 ? 1 : a, j = 6 & (c = a && (b = a)); + int d = 0, e = a, f = ~c, g = b || a; + unsigned char h = ~a; + if (a) + f = j; + if (h && g) + d = a; + i = -~(f * d * h) + c && (e || i) ^ f; + if (i != 1) + __builtin_abort (); +} + +int +main () +{ + fn1 (); + return 0; +} diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c index 307bb1f..e2e8212 100644 --- a/gcc/tree-ssa-uncprop.c +++ b/gcc/tree-ssa-uncprop.c @@ -95,7 +95,8 @@ associate_equivalences_with_edges (void) if (TREE_CODE (op0) == SSA_NAME && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op0) && ssa_name_has_boolean_range (op0) - && is_gimple_min_invariant (op1)) + && is_gimple_min_invariant (op1) + && (integer_zerop (op1) || integer_onep (op1))) { tree true_val = constant_boolean_node (true, TREE_TYPE (op0)); tree false_val = constant_boolean_node (false,