From patchwork Thu Oct 9 09:00:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 397940 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 108791400B2 for ; Thu, 9 Oct 2014 20:04:09 +1100 (EST) 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=kFLU+pliuyOCnykPxzFh+AZb4VhZOFu6VMiaCSR5NxhEAIHzLxewD NP0f/Wjwc5tSaE5yQxG3iaANPcf/sM1CDFLskH3HqgaFIdPVvnb08ZFWjLJgRnCH 51BpI/XY1jqf8LA8OO/9/He2RLnRNT/PLCrtl67OyogmkrP1S6FXtk= 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=B/gIkSQ5EJqm6bhjNTw5LZu2Drw=; b=uacTZ25KDHda/xXrlSDV bczWjggoHRbRIOYNQnYkzHGVZnEFlCWiNiARPuB90IaJ69xMg+RcGOjNX5yN2mfB 5jYByJu19UHMJ+OhjzudMYbh0Hiw8UlO0i7lB0mDcdnqQFYoNsp961TXQ9YjNRuj t3k2hFe9FDytFaZdYGb2EIU= Received: (qmail 17740 invoked by alias); 9 Oct 2014 09:04:02 -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 17729 invoked by uid 89); 9 Oct 2014 09:04:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 09 Oct 2014 09:04:00 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9D709AAF3 for ; Thu, 9 Oct 2014 09:03:57 +0000 (UTC) Date: Thu, 9 Oct 2014 11:00:04 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR63380 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 The following fixes PR63380 by making sure to not ignore unused but possibly trapping stmts when comparing basic-blocks. Bootstrap / regtest running on x86_64-unknown-linux-gnu. Richard. 2014-10-09 Richard Biener PR tree-optimization/63380 * tree-ssa-tail-merge.c (stmt_local_def): Exclude stmts that may trap. * gcc.dg/torture/pr63380-1.c: New testcase. Index: gcc/tree-ssa-tail-merge.c =================================================================== --- gcc/tree-ssa-tail-merge.c (revision 215917) +++ gcc/tree-ssa-tail-merge.c (working copy) @@ -313,9 +313,9 @@ stmt_local_def (gimple stmt) tree val; def_operand_p def_p; - if (gimple_has_side_effects (stmt) - || stmt_could_throw_p (stmt) - || gimple_vdef (stmt) != NULL_TREE) + if (gimple_vdef (stmt) != NULL_TREE + || gimple_has_side_effects (stmt) + || gimple_could_trap_p_1 (stmt, false, false)) return false; def_p = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_DEF); Index: gcc/testsuite/gcc.dg/torture/pr63380-1.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr63380-1.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr63380-1.c (working copy) @@ -0,0 +1,15 @@ +/* { dg-do run } */ + +int a = 0, b = 1, c = 0, d = 1, e, f, g, h; +int +main () +{ + e = 1 >> d; + f = ((31 / (1 > e)) || c) / 2; + g = b || a; + h = 31 / g; + if (!h) + __builtin_abort(); + return 0; +} + Index: gcc/testsuite/gcc.dg/torture/pr63380-2.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr63380-2.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr63380-2.c (working copy) @@ -0,0 +1,10 @@ +/* { dg-do run } */ + +int a = 0, b = 0, c = 0, d, e; +int +main (void) +{ + d = ((20 % (1 != b)) && c) + 2147483647; + e = 20 % (a >= 0); + return 0; +}