From patchwork Thu Apr 27 13:49:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 756036 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 3wDJH23pVXz9sNX for ; Thu, 27 Apr 2017 23:50:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SveCMxwW"; 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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=uM3iv/pdZNpdNH1WSat2pJZA0s1DYFrJCGScURWs4a8TMrJ8VVai4 hyOwKBvWREdD5uRDR//Db0tVywCL32x1Fq0PqC7MiAp8aEgdv7j36UGYVsB45K5F v7dDPbEDu9YOJI84fOJdC1wr4vGuBoxhqvQ3z9xaiBK93RaFxkk+38= 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:mime-version:content-type; s= default; bh=vsZXBxxjYhsb8hbAYUdXDCtwEQE=; b=SveCMxwWfXSt0aJSwb5l lyiAKZSV5Cu+UdgE7+JaIWe7wmI3UfPKIlSYAOGY9btHXzh2CVMuiCIOiL5uVSQG CNqfawxJmzyRZclJoeR51XBdGjhcazhZ3rSlbQMZffk9YAm8hG0YiwzNqniZKisq qAtvdhs8TC0nGMQOCYBKzvQ= Received: (qmail 122564 invoked by alias); 27 Apr 2017 13:49:42 -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 122178 invoked by uid 89); 27 Apr 2017 13:49:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=partly X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Apr 2017 13:49:40 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6E00AAEDE for ; Thu, 27 Apr 2017 13:49:40 +0000 (UTC) Date: Thu, 27 Apr 2017 15:49:40 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Improve VRP range intersection for partly symbolic ranges Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following makes intersecting [-INF, +10] and [a + -1, +INF] to [10, a + -1] possible with the chance that for a <= 10 the resulting range will be empty (but not trivially visible as so). Bootstrap / regtest running on x86_64-unknown-linux-gnu. I'll add a testcase later. Richard. 2017-04-27 Richard Biener * tree-vrp.c (intersect_ranges): Better handle partly symbolic ranges. Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c (revision 247334) +++ gcc/tree-vrp.c (working copy) @@ -8989,6 +8989,28 @@ intersect_ranges (enum value_range_type else gcc_unreachable (); } + else if (operand_less_p (*vr0min, vr1max) == 1 + && operand_less_p (*vr0min, vr1min) == 1 + && operand_less_p (*vr0max, vr1max) == 1 + && operand_less_p (vr1min, *vr0max) == -2) + { + /* [ (] ) with ] and ( being unordered as (partly) symbolic. + This can result in ranges that are effectively empty. */ + if (*vr0type == VR_RANGE + && vr1type == VR_RANGE) + *vr0min = vr1min; + } + else if (operand_less_p (vr1min, *vr0max) == 1 + && operand_less_p (vr1min, *vr0min) == 1 + && operand_less_p (vr1max, *vr0max) == 1 + && operand_less_p (*vr0min, vr1max) == -2) + { + /* ( [) ] with ] and ( being unordered as (partly) symbolic. + This can result in ranges that are effectively empty. */ + if (*vr0type == VR_RANGE + && vr1type == VR_RANGE) + *vr0max = vr1max; + } /* As a fallback simply use { *VRTYPE, *VR0MIN, *VR0MAX } as result for the intersection. That's always a conservative