From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113315 invoked by alias); 23 Nov 2015 11:06:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 113301 invoked by uid 89); 23 Nov 2015 11:06:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Nov 2015 11:06:35 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B85BE49; Mon, 23 Nov 2015 03:06:16 -0800 (PST) Received: from [10.2.206.22] (e104437-lin.cambridge.arm.com [10.2.206.22]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2D9E23F21A; Mon, 23 Nov 2015 03:06:33 -0800 (PST) To: GCC Patches Cc: Richard Biener From: Jiong Wang Subject: [Patch] PR68137, drop constant overflow flag in adjust_range_with_scev when possible Message-ID: <5652F337.8090800@foss.arm.com> Date: Mon, 23 Nov 2015 11:08:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070702030001000608080303" X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg02682.txt.bz2 This is a multi-part message in MIME format. --------------070702030001000608080303 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 932 As reported by pr68137 and pr68326, r230150 caused new issues. Those ICEs are caused by adjust_range_with_scev getting range with overflowed constants min or max. So given there are too many places to generate OVF, we do a check in adjust_range_with_scev, to drop OVF flag when it's uncessary. This should fix the OVF side-effect caused by r230150. A simple regression testcase is included in this patch. bootstrap OK on x86-64 and aarch64, regression ok on both. For more background, please see discussion at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68317 OK for trunk? 2015-11-23 Richard Biener Jiong Wang gcc/ PR tree-optimization/68137 PR tree-optimization/68326 * tree-vrp.c (adjust_range_with_scev): Call drop_tree_overflow if the final min and max are not infinity. gcc/testsuite/ * gcc.dg/pr68139.c: New testcase. -- Regards, Jiong --------------070702030001000608080303 Content-Type: text/x-patch; name="new.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="new.patch" Content-length: 1266 diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index e2393e4..8efeb76 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4331,6 +4331,17 @@ adjust_range_with_scev (value_range *vr, struct loop *loop, && is_positive_overflow_infinity (max))) return; + /* Even for valid range info, sometimes overflow flag will leak in. + As GIMPLE IL should have no constants with TREE_OVERFLOW set, we + drop them except for +-overflow_infinity which still need special + handling in vrp pass. */ + if (TREE_OVERFLOW_P (min) + && ! is_negative_overflow_infinity (min)) + min = drop_tree_overflow (min); + if (TREE_OVERFLOW_P (max) + && ! is_positive_overflow_infinity (max)) + max = drop_tree_overflow (max); + set_value_range (vr, VR_RANGE, min, max, vr->equiv); } diff --git a/gcc/testsuite/gcc.dg/pr68137.c b/gcc/testsuite/gcc.dg/pr68137.c new file mode 100644 index 0000000..a30e1ac --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr68137.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void bar (int); + +void +foo () +{ + int index = 0; + for (index; index <= 10; index--) + /* Result of the following multiply will overflow + when converted to signed int. */ + bar((0xcafe + index) * 0xdead); +} --------------070702030001000608080303--