From patchwork Thu Mar 7 13:49:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 225856 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]) by ozlabs.org (Postfix) with SMTP id 1389D2C02B2 for ; Fri, 8 Mar 2013 00:49:31 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1363268972; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=p4MhZ5evEza1kK7BfxtF OtYyNso=; b=OrSxujacc4Boinn56N4uR0n/d9+63mIUn1QyYfu8FZHil2epxDEq fJ7va1WjniXrlUPbi9K/E35uVl2EIfHBmZJcuuUvcTveIaeo7PJRwtCe9C0LJ755 3ip4CXFfZGFoHCs9rZFJB5g1hP5w5VSKrTnYVOQOnmz8WAX9Okz7WHM= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=KQxIizc3asm61tS+ERiRhPzR/4nrwk4odTaz6DJ9phK/NfbMpzVWFjPe6vkKM1 aQ1UaqX99ny1zzYu+xzHx6Dttze7t3tZqiSRVJAEMs2tRq0epWUXCndpVmIrewfL J5GQzItnOqFTYzf/wGGHcymPABcKTF9aFNUGY4XiujahE=; Received: (qmail 29504 invoked by alias); 7 Mar 2013 13:49:23 -0000 Received: (qmail 29486 invoked by uid 22791); 7 Mar 2013 13:49:21 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Mar 2013 13:49:14 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r27DnD0x011980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Mar 2013 08:49:13 -0500 Received: from zalov.cz (vpn1-6-140.ams2.redhat.com [10.36.6.140]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r27DnB76031070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 7 Mar 2013 08:49:12 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r27DnABg022845; Thu, 7 Mar 2013 14:49:10 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r27DnAO8022844; Thu, 7 Mar 2013 14:49:10 +0100 Date: Thu, 7 Mar 2013 14:49:09 +0100 From: Jakub Jelinek To: Richard Biener , Bill Schmidt Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix reassoc ICE (PR tree-optimization/56559) Message-ID: <20130307134909.GB12913@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! During zero_one_operation I believe we can count in the chain having single uses if we go through rhs1s, but the change from last year also added looking through rhs2, and there I don't see anything that would guarantee a single use, and the following testcase shows where it has two uses. If it has more than one use, obviously we can't change the pow call just because in one of the uses we'd like to remove one multiplication. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-03-07 Jakub Jelinek PR tree-optimization/56559 * tree-ssa-reassoc.c (zero_one_operation): When looking at rhs2, check that it has only a single use. * gcc.dg/tree-ssa/reassoc-26.c: New test. Jakub --- gcc/tree-ssa-reassoc.c.jj 2013-02-18 16:39:55.000000000 +0100 +++ gcc/tree-ssa-reassoc.c 2013-03-07 10:09:22.048925800 +0100 @@ -1107,7 +1107,8 @@ zero_one_operation (tree *def, enum tree the operand might be hiding in the rightmost one. */ if (opcode == MULT_EXPR && gimple_assign_rhs_code (stmt) == opcode - && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME) + && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME + && has_single_use (gimple_assign_rhs2 (stmt))) { gimple stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs2 (stmt)); if (stmt_is_power_of_op (stmt2, op)) --- gcc/testsuite/gcc.dg/tree-ssa/reassoc-26.c.jj 2013-03-07 10:10:49.400749110 +0100 +++ gcc/testsuite/gcc.dg/tree-ssa/reassoc-26.c 2013-03-07 10:10:18.000000000 +0100 @@ -0,0 +1,12 @@ +/* PR tree-optimization/56559 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +double a, b, c, d, e; + +void +foo () +{ + a = e * e; + b = d * e + c * e * a; +}