From patchwork Mon Dec 2 22:47:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 296027 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 078EE2C009F for ; Tue, 3 Dec 2013 09:47:23 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=lixyUs1HxkQrHSyFcCCCf4xZBB+nFEwYHbDtayY+iME R3aYldMmXY8UCPRHb+rfImPjMCLCrtl4b+QkVQ+dlnffVeIN6lfXzPsuPEwPOfPD mZopx/nxvyLNzCdq6HffUmequA4QKd5heldnH84D8NMblXpdIa5CCAEmMGkWmPYQ = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=Rk2dttOzuVTHOS1u4O6HMAGbt1U=; b=Vkn6/q3eohi93oA5M IfdUzUaHSqwre5CvPzeENTcseaICpAI2JdOJCmasN4kdPzpmhlBNEhq1Dy8jsAdH kpEBhg0cysE0h8rdY7mYylhoC6xUTKPOiDfFtzhZZBJNTC0JaSQV2k2X+WMJFwNn lqrjFgpWbuiE1fvECdN3J4VKFs= Received: (qmail 27143 invoked by alias); 2 Dec 2013 22:47:14 -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 27129 invoked by uid 89); 2 Dec 2013 22:47:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_05, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Dec 2013 22:47:12 +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 (8.14.4/8.14.4) with ESMTP id rB2Ml4hx025516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 2 Dec 2013 17:47:05 -0500 Received: from tucnak.zalov.cz (vpn1-7-223.ams2.redhat.com [10.36.7.223]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB2Ml3ln004456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 2 Dec 2013 17:47:04 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.7/8.14.7) with ESMTP id rB2Ml2Vc016460 for ; Mon, 2 Dec 2013 23:47:02 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.7/8.14.7/Submit) id rB2Ml2mA016459 for gcc-patches@gcc.gnu.org; Mon, 2 Dec 2013 23:47:02 +0100 Date: Mon, 2 Dec 2013 23:47:02 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix VRP range meet (PR tree-optimization/59358) Message-ID: <20131202224702.GR892@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi! The following testcase is miscompiled (to endless loop), because union_ranges didn't count with the possibility that *vr0max and vr1max are uncomparable (one of them is symbolic). Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, preapproved by richi on IRC, committed to trunk/4.8. 2013-12-02 Jakub Jelinek PR tree-optimization/59358 * tree-vrp.c (union_ranges): To check for the partially overlapping ranges or adjacent ranges, also compare *vr0max with vr1max. * gcc.c-torture/execute/pr59358.c: New test. Jakub --- gcc/tree-vrp.c.jj 2013-11-28 23:51:58.000000000 +0100 +++ gcc/tree-vrp.c 2013-12-02 13:24:10.750956769 +0100 @@ -7758,7 +7758,8 @@ union_ranges (enum value_range_type *vr0 } else if ((operand_less_p (vr1min, *vr0max) == 1 || operand_equal_p (vr1min, *vr0max, 0)) - && operand_less_p (*vr0min, vr1min) == 1) + && operand_less_p (*vr0min, vr1min) == 1 + && operand_less_p (*vr0max, vr1max) == 1) { /* [ ( ] ) or [ ]( ) */ if (*vr0type == VR_RANGE @@ -7792,7 +7793,8 @@ union_ranges (enum value_range_type *vr0 } else if ((operand_less_p (*vr0min, vr1max) == 1 || operand_equal_p (*vr0min, vr1max, 0)) - && operand_less_p (vr1min, *vr0min) == 1) + && operand_less_p (vr1min, *vr0min) == 1 + && operand_less_p (vr1max, *vr0max) == 1) { /* ( [ ) ] or ( )[ ] */ if (*vr0type == VR_RANGE --- gcc/testsuite/gcc.c-torture/execute/pr59358.c.jj 2013-12-02 13:26:33.984198815 +0100 +++ gcc/testsuite/gcc.c-torture/execute/pr59358.c 2013-12-02 13:26:17.000000000 +0100 @@ -0,0 +1,44 @@ +/* PR tree-optimization/59358 */ + +__attribute__((noinline, noclone)) int +foo (int *x, int y) +{ + int z = *x; + if (y > z && y <= 16) + while (y > z) + z *= 2; + return z; +} + +int +main () +{ + int i; + for (i = 1; i < 17; i++) + { + int j = foo (&i, 16); + int k; + if (i >= 8 && i <= 15) + k = 16 + (i - 8) * 2; + else if (i >= 4 && i <= 7) + k = 16 + (i - 4) * 4; + else if (i == 3) + k = 24; + else + k = 16; + if (j != k) + __builtin_abort (); + j = foo (&i, 7); + if (i >= 7) + k = i; + else if (i >= 4) + k = 8 + (i - 4) * 2; + else if (i == 3) + k = 12; + else + k = 8; + if (j != k) + __builtin_abort (); + } + return 0; +}