From patchwork Thu Nov 14 19:03:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1195118 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513454-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="UCgvk1c9"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="GpPoECJU"; dkim-atps=neutral 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 47DW9H179Kz9sPc for ; Fri, 15 Nov 2019 06:03:46 +1100 (AEDT) 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=JUp3LxurTmX8jqWK7LbOYzO9GUuLbTJbjvfGJ4+KH/nnXya7CZ aOjLzxRoSFO/5/A6ySDtgEpnHNCqOqXXJOsDY/P57SK15guAZjlK6jq3Zux+QUED rupboprAsmxbHK0yYX0gvfIsYenkZEEZAPjG+md5xRzg4JTOiRVRuRdzg= 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=IsYl/RHp/uYVTEhwZSk+vRyQli8=; b=UCgvk1c9ajLRAnyBxQE3 L2bQX2bRbaeWjX5xxgl0of8qoQCl62KyyYLBA8MSHVEx/ichpecDk3yDEFoM6Kh+ 4ZafwuO8yrlrPBFoWGypASBIfCWIB8Igdoo7vbbGwJsNUmYo8NwZApHiQ6OcI8En vQUev1JNDNZR3uPX98iAm9w= Received: (qmail 23383 invoked by alias); 14 Nov 2019 19:03:39 -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 23375 invoked by uid 89); 14 Nov 2019 19:03:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2 autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1928, H*M:4d2e X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Nov 2019 19:03:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573758215; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=Eo94mQu2Hr1Fym3sbMHkqZXxdi3+oWT0gMKY8VksZ3E=; b=GpPoECJUnXgDYV7Z1NXTihLxPnUtsXzL415H2j5NT8RhvDhxNGD3pcvTqX/gadhAOAB+6Z Z05mhqrEPxIN2bsUpYuly0fGg9l7ACC5g3hRkU+eP+1I/JTzfjI+cBDWAhfebgxh5dXtiQ aZHuLKhanstzW/tj91+We2CzO/jog2o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-GcpS0ocOOSeOeVFvclK6wQ-1; Thu, 14 Nov 2019 14:03:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D3AE107ACC5 for ; Thu, 14 Nov 2019 19:03:32 +0000 (UTC) Received: from [10.10.123.247] (ovpn-123-247.rdu2.redhat.com [10.10.123.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9ECAE60856 for ; Thu, 14 Nov 2019 19:03:31 +0000 (UTC) To: gcc-patches From: Andrew MacLeod Subject: [committed] operator_abs::fold_range() returning incorrect result for overflows (pr92506) Message-ID: Date: Thu, 14 Nov 2019 14:03:30 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes Traced it back to a typo in operator_abs::fold_range() when I did the conversion where the wrong line got copied in.. Instead of returning value_range (type) when a overflow happens, it was returning the same result of the previous check, which was the case for all positives. This had EVRP setting the range of an ABS to [-MIN, -1] instead of varying, which later caused VRP to intersect that with 0 - [-MIN, -1] and all heck broke loose. doh. I also stumbled across a case where we should be starting with undefined in the default fold_range() and building with union for each sub-range.  We previously declared a local value_range to work with, and that defaulted to undefined.  When I changed it to a reference parameter, I need to explicitly initialize it. Bootstraps, checked in as revision 278259. Andrew 2019-11-14 Andrew MacLeod * range-op.cc (range_operator::fold_range): Start with range undefined. (operator_abs::wi_fold): Fix wrong line copy... With wrapv, abs with overflow is varying. Index: range-op.cc =================================================================== *** range-op.cc (revision 277979) --- range-op.cc (working copy) *************** range_operator::fold_range (value_range *** 146,151 **** --- 146,152 ---- return; value_range tmp; + r.set_undefined (); for (unsigned x = 0; x < lh.num_pairs (); ++x) for (unsigned y = 0; y < rh.num_pairs (); ++y) { *************** operator_abs::wi_fold (value_range &r, t *** 2359,2365 **** wide_int max_value = wi::max_value (prec, sign); if (!TYPE_OVERFLOW_UNDEFINED (type) && wi::eq_p (lh_lb, min_value)) { ! r = value_range (type, lh_lb, lh_ub); return; } --- 2360,2366 ---- wide_int max_value = wi::max_value (prec, sign); if (!TYPE_OVERFLOW_UNDEFINED (type) && wi::eq_p (lh_lb, min_value)) { ! r = value_range (type); return; }