From patchwork Mon Feb 1 15:34:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 576579 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 50C05140AD9 for ; Tue, 2 Feb 2016 02:34:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=UJsCSSdY; dkim-atps=neutral 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=UyoOYBVNLDeaJW7HPvQ+5U/hv1P26vpitYv5b77kt5sV0nZx8vyIS jUFoCWKU+FbBBPqiywOi9s+I3CB2WAhS3Ru2u1MpSDeo2kFUbC5VogHJ107zyDym n6/KFAbumHeBzsti267cZcGsEqf5CpPGmC6p1HshPlnMapbOjZL7Zw= 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=+qvBvYBfG9Y5RpGAHlkcJ1uWF9U=; b=UJsCSSdY1P3TWNtqu/bB KxZ4pmR+srfvv85htaeygqGD6K4j6Tak3ZcJHFUJXsEgK/RzDLwHDGRO+dkHItjT ZGMCDKcFfsPlWr+KT6euyJwXrnN5Dod8zRlPHbn/cIR87tm5Y3VTLVRX22fmO/W5 Y1J9TEtGaCrsWgHhE4J5fQA= Received: (qmail 75893 invoked by alias); 1 Feb 2016 15:34:33 -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 75797 invoked by uid 89); 1 Feb 2016 15:34:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1303, 80 X-HELO: mx2.suse.de Received: from mx2.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; Mon, 01 Feb 2016 15:34:31 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9FA19AABB for ; Mon, 1 Feb 2016 15:34:28 +0000 (UTC) Date: Mon, 1 Feb 2016 16:34:28 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR69556 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2016-02-01 Richard Biener PR middle-end/69556 * match.pd: Guard (C1/X)*C2 -> (C1*C2)/X with single_use. * gcc.dg/tree-ssa/recip-8.c: New testcase. Index: gcc/match.pd =================================================================== --- gcc/match.pd (revision 233033) +++ gcc/match.pd (working copy) @@ -445,8 +445,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* Fold (C1/X)*C2 into (C1*C2)/X. */ (simplify - (mult (rdiv:s REAL_CST@0 @1) REAL_CST@2) - (if (flag_associative_math) + (mult (rdiv@3 REAL_CST@0 @1) REAL_CST@2) + (if (flag_associative_math + && single_use (@3)) (with { tree tem = const_binop (MULT_EXPR, type, @0, @2); } (if (tem) Index: gcc/testsuite/gcc.dg/tree-ssa/recip-8.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/recip-8.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/recip-8.c (working copy) @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -fdump-tree-optimized" } */ + +double bar (double, double, double, double, double); + +double +foo (double a) +{ + return bar (1.0/a, 2.0/a, 4.0/a, 8.0/a, 16.0/a); +} + +/* { dg-final { scan-tree-dump-times "/" 1 "optimized" } } */