From patchwork Fri May 3 16:36:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 241351 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id EE7C22C009D for ; Sat, 4 May 2013 02:36:56 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=DDT2oXXuCgLBetps/r03B7tCn3Oovd6WaWytFHQ3yyD2Dz zfhdtVmWRvcU/GdQjdO0m5zvU8wiaApSJLfusmMUsL8PPBWB2NaYArUG6WkmvUhX 1xOYSxuAXLcvP/gAp1lwV6cnLXd8Hhnq4OW6OZ4YyZH7l+jD1PUKfPSv1vHaE= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=UZRCvQ/7CB0ha36RHwkEy5gntdM=; b=Agc3vGNHnfMIALttwD0i sNl6PegYgaH154HII9sMKNt2GpeIL2QOl1xO3T8W6lh5R+lsuHyyg6VDPFOxjXSc irD/pj/eOMdRiESU4nBooqoi547Azw5ywrLWZJyWMNPbyFS6ogWP9ukVrHCOEB/u DJDDY4HKx1O3N8N+/8aEWCg= Received: (qmail 21377 invoked by alias); 3 May 2013 16:36:50 -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 21368 invoked by uid 89); 3 May 2013 16:36:49 -0000 X-Spam-SWARE-Status: No, score=-8.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 03 May 2013 16:36:49 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r43GalNw017676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 3 May 2013 12:36:47 -0400 Received: from stumpy.slc.redhat.com (ovpn-113-32.phx2.redhat.com [10.3.113.32]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r43GalBv012730 for ; Fri, 3 May 2013 12:36:47 -0400 Message-ID: <5183E79F.6050100@redhat.com> Date: Fri, 03 May 2013 10:36:47 -0600 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5 MIME-Version: 1.0 To: gcc-patches Subject: [PATCH] Fix tree-optimization/57144 X-Virus-Found: No Only change is in the new test which incorporates Jakub's comments. Installed onto the trunk. commit e30e5a25cb9b1888b48531d87573a833515a1e4b Author: Jeff Law Date: Thu May 2 22:19:37 2013 -0600 PR tree-optimization/57411 * tree-vrp.c (simplify_cond_using_ranges): Verify the constant operand of the condition will bit into the new type when eliminating a cast feeding a condition. PR tree-optimization/57411 * gcc.c-torture/execute/pr57144.c: New test. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9e3d783..f245097 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2013-05-02 Jeff Law + + PR tree-optimization/57411 + * tree-vrp.c (simplify_cond_using_ranges): Verify the constant + operand of the condition will bit into the new type when eliminating + a cast feeding a condition. + 2013-05-02 Richard Biener * tree-eh.c (cleanup_empty_eh_merge_phis): Remove rename_virts diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c8dc189..be30c51 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-05-02 Jeff Law + + PR tree-optimization/57411 + * gcc.c-torture/execute/pr57144.c: New test. + 2013-05-02 Tobias Burnus PR fortran/57142 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr57144.c b/gcc/testsuite/gcc.c-torture/execute/pr57144.c new file mode 100644 index 0000000..ffa2df4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr57144.c @@ -0,0 +1,19 @@ +extern void abort (void); +extern void exit (int); + +void __attribute__ ((noinline)) +foo(int a) +{ + int z = a > 0 ? a : -a; + long long x = z; + if (x > 0x100000000LL) + abort (); + else + exit (0); +} + +int +main() +{ + foo (1); +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 6ed353f..b5de683 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -8668,7 +8668,8 @@ simplify_cond_using_ranges (gimple stmt) if (range_int_cst_p (vr) && range_fits_type_p (vr, TYPE_PRECISION (TREE_TYPE (op0)), - TYPE_UNSIGNED (TREE_TYPE (op0)))) + TYPE_UNSIGNED (TREE_TYPE (op0))) + && int_fits_type_p (op1, TREE_TYPE (innerop))) { tree newconst = fold_convert (TREE_TYPE (innerop), op1); gimple_cond_set_lhs (stmt, innerop);