From patchwork Sun Jun 9 16:25:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 250068 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 7DF882C02B1 for ; Mon, 10 Jun 2013 02:25: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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=GjG42ja8pIRU6JvdEKwYFbNOaZawn4Vhysdke5oJQfA7WuZuKCgO2 JHcX6mdGmGBhT+H0pLg7DXNzlzgHIqO/HhrIo1Ev0rBP/UMf8LNxri/a/NsbpCGG cYixjKLnJ45tskVtfATPE50622CGmd6wjTB5LUs2zjVJj9wBhzPyCA= 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=q4MFUY3SXebFauyFSZ2rsWK8ncI=; b=Dx6SqjDP5aJVD3dUSR3Q W3fhhQO/FSB5aLcQu1RmNOutrLz6CeyGx2ZMmmRDU8JB7SmEHkFxR1PTrJPqI2zx sDaZcomMhbJAoD9nQLaSUgd0MXvDIz2dkpJzZfcjb6AuBxwLVnWIpfefxB8JgHN8 moa0vntQTxDko3HMYkr1dPk= Received: (qmail 931 invoked by alias); 9 Jun 2013 16:25: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 921 invoked by uid 89); 9 Jun 2013 16:25:49 -0000 X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_TM autolearn=ham version=3.3.1 Received: from mail2-relais-roc.national.inria.fr (HELO mail2-relais-roc.national.inria.fr) (192.134.164.83) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 09 Jun 2013 16:25:48 +0000 Received: from stedding.saclay.inria.fr ([193.55.250.194]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 09 Jun 2013 18:25:46 +0200 Received: from glisse (helo=localhost) by stedding.saclay.inria.fr with local-esmtp (Exim 4.80) (envelope-from ) id 1UliR8-0006Pa-3M for gcc-patches@gcc.gnu.org; Sun, 09 Jun 2013 18:25:46 +0200 Date: Sun, 9 Jun 2013 18:25:46 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org Subject: Remove self-assignments Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-Virus-Found: No Hello, this patch removes some self-assignments. I don't know if this is the best way, but it passes a bootstrap and the testsuite on x86_64-linux-gnu. 2013-06-10 Marc Glisse PR tree-optimization/57361 gcc/ * tree-ssa-dse.c (dse_possible_dead_store_p): Handle self-assignment. gcc/testsuite/ * gcc.dg/tree-ssa/pr57361.c: New file. Index: testsuite/gcc.dg/tree-ssa/pr57361.c =================================================================== --- testsuite/gcc.dg/tree-ssa/pr57361.c (revision 0) +++ testsuite/gcc.dg/tree-ssa/pr57361.c (revision 0) @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-dse1-details" } */ + +struct A { int x; double y; }; +void f (struct A *a) { + *a = *a; +} + +/* { dg-final { scan-tree-dump "Deleted dead store" "dse1"} } */ Property changes on: testsuite/gcc.dg/tree-ssa/pr57361.c ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision URL Added: svn:eol-style + native Index: tree-ssa-dse.c =================================================================== --- tree-ssa-dse.c (revision 199867) +++ tree-ssa-dse.c (working copy) @@ -77,20 +77,29 @@ static void dse_enter_block (struct dom_ Return TRUE if the above conditions are met, otherwise FALSE. */ static bool dse_possible_dead_store_p (gimple stmt, gimple *use_stmt) { gimple temp; unsigned cnt = 0; *use_stmt = NULL; + /* Self-assignments are zombies. */ + if (gimple_assign_rhs_code (stmt) == TREE_CODE (gimple_assign_lhs (stmt)) + && operand_equal_p (gimple_assign_rhs1 (stmt), + gimple_assign_lhs (stmt), 0)) + { + *use_stmt = stmt; + return true; + } + /* Find the first dominated statement that clobbers (part of) the memory stmt stores to with no intermediate statement that may use part of the memory stmt stores. That is, find a store that may prove stmt to be a dead store. */ temp = stmt; do { gimple use_stmt, defvar_def; imm_use_iterator ui; bool fail = false;