From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81670 invoked by alias); 28 Feb 2019 17:05:47 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 81647 invoked by uid 89); 28 Feb 2019 17:05:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=Meet, Meeting, meet X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Feb 2019 17:05:46 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1SH3XDw062482; Thu, 28 Feb 2019 17:05:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : content-type : content-transfer-encoding : mime-version : subject : message-id : date : to; s=corp-2018-07-02; bh=0Ahe/32bnsO03FyWddGFOMhUHZ9eWrax0k5XRf9+aX0=; b=dTzC1c2MJxxO1L87/PuRLcfbVh8zP6n9sQ6tH68dbNUvVFFDgERs6c23ZERDuCGtlxV6 08jOsZQ2Rs027yKFZDwuCB97Pv8nmpYe55J9a3ihOXuWySOuBvQcfrOr4DjjTqd33NCK L8Ut563UL+fChXU2J29NnxgB4YOrjERAQBUQk/ClY/KfXYgYa/r1MHqZom/Z+9S6sdfu Za7WtiaDL50FuxdX6kI55w/tKLKsfqWAPSS2VKYDLzp42KkJEoXx6svpalj8r392YK7R y/PaTeG0eZ+ABN1jT3RXMLLGGUwqp5kVk+NshZ9nY1jKwlEfW4iOuvuGdEyLjtLJkBD+ 2g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2qtwkuje2p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Feb 2019 17:05:43 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1SH5b2A031760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Feb 2019 17:05:37 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1SH5aa8012100; Thu, 28 Feb 2019 17:05:37 GMT Received: from dhcp-10-159-252-223.vpn.oracle.com (/10.159.252.223) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 28 Feb 2019 09:05:36 -0800 From: Qing Zhao Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: A bug in vrp_meet? Message-Id: Date: Thu, 28 Feb 2019 17:05:00 -0000 To: gcc@gcc.gnu.org, gcc Patches X-IsSubscribed: yes X-SW-Source: 2019-02/txt/msg00172.txt.bz2 Hi, I have been debugging a runtime error caused by value range propagation. an= d finally located to the following gcc routine: vrp_meet_1 in gcc/tree-vrp.c =3D=3D=3D=3D /* Meet operation for value ranges. Given two value ranges VR0 and VR1, store in VR0 a range that contains both VR0 and VR1. This may not be the smallest possible such range. */ static void=20 vrp_meet_1 (value_range *vr0, const value_range *vr1) { value_range saved; if (vr0->type =3D=3D VR_UNDEFINED) {=20=20=20=20 set_value_range (vr0, vr1->type, vr1->min, vr1->max, vr1->equiv); return; }=20=20=20=20 if (vr1->type =3D=3D VR_UNDEFINED) {=20=20=20=20 /* VR0 already has the resulting range. */ return; }=20=20=20=20 =3D=3D=3D=3D In the above, when one of vr0 or vr1 is VR_UNDEFINED, the meet result of t= hese two will be the other VALUE.=20 This seems not correct to me.=20 For example, the following is the located incorrect value range propagation= : (portion from the dump file *.181t.dom3) =3D=3D=3D=3D Visiting PHI node: i_83 =3D PHI <_152(20), 0(22)> Argument #0 (20 -> 10 executable) _152: UNDEFINED Argument #1 (22 -> 10 executable) 0: [0, 0] Meeting UNDEFINED and [0, 0] to [0, 0] Intersecting [0, 0] and [0, 65535] to [0, 0] =3D=3D=3D=3D In the above, =E2=80=9Ci_83=E2=80=9D is defined as PHI <_152(20), 0(22)>, = the 1st argument is UNDEFINED at this time(but its value range definitely = is NOT [0,0]), and the 2nd argument is 0. =E2=80=9Cvrp_meet=E2=80=9D generate a VR_RANGE with [0,0] for =E2=80=9Ci_83= =E2=80=9D based on the current algorithm. Obviously, this result VR_RANGE = with [0,0] does NOT=20 contain the value ranges for _152.=20 the result of =E2=80=9Cvrp_meet=E2=80=9D is Not correct. and this incorre= ct value range result finally caused the runtime error.=20 I =E2=80=98d like to modify the vrp_meet_1 as following: =3D=3D=3D=3D static void=20 vrp_meet_1 (value_range *vr0, const value_range *vr1) { value_range saved; if (vr0->type =3D=3D VR_UNDEFINED) {=20=20=20=20 /* VR0 already has the resulting range. */ return; }=20=20=20=20 if (vr1->type =3D=3D VR_UNDEFINED) {=20=20=20=20 set_value_range_to_undefined (vr0) return; }=20=20=20=20 =3D=3D=3D=3D let me know your opinion. thanks a lot for the help. Qing