From patchwork Tue Feb 13 17:54:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 873186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-473213-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="qMqbQb+A"; dkim-atps=neutral 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 3zgx5m6fcTz9t3B for ; Wed, 14 Feb 2018 08:49:46 +1100 (AEDT) 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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=IWcxea1egSRtCuyOfPfFK/h3HlQau qTNrB0uHibtr6wkKQ/3OHbOyvZS51byIzHpeySnXyxNgoST+5mKnWj5ez5lddoZe VBmjhXxnaCBLnO7GPvxXNwg8mtpM2Ac05tjkiE7Lf/OGuJI2D5gptNCqku/gbgqt mQOBclPCT92dLY= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=g/0ziy6JWZUGbwhpVfTc2hiiHe0=; b=qMq bQb+AZDaKtzJhJFo0KO1t6SCEEtIDRa5KhP8w3Dc2G4a8dnzeufmPoFHxwNGXaMw 45zk27PB/zsifP8kFCi4LgeUmrYel1JQ+nO0ItHKYnoukCE2wvPklDn9GJdjAMbZ 8lIfrL3xfoXS95jH6rIv+UGOokR3tFz1APXwQ71I= Received: (qmail 124902 invoked by alias); 13 Feb 2018 21:49:39 -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 124893 invoked by uid 89); 13 Feb 2018 21:49:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Feb 2018 21:49:37 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B220C40FB645 for ; Tue, 13 Feb 2018 21:49:30 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-85.brq.redhat.com [10.40.204.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F378E1007D67 for ; Tue, 13 Feb 2018 21:49:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w1DHsbSP023757; Tue, 13 Feb 2018 18:54:37 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w1DHsaKe023756; Tue, 13 Feb 2018 18:54:36 +0100 Date: Tue, 13 Feb 2018 18:54:36 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix a brown paper bag bug in my recent match.pd change (PR middle-end/84309) Message-ID: <20180213175436.GT5867@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes Hi! When changing my recent match.pd fix to defer the -> exp2 (log2 (C) * x) optimization until later, I've swapped the two patterns and changed the first one to use exps and logs, but forgot to change the second one to use exp2s and log2s. For the testcase in the patch it actually didn't make a difference, it was enough that we deferred optimizing it (because we shortly afterwards propagated constants into the pow and constant folded it). This patch adds a testcase that verifies it is done properly. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-02-13 Jakub Jelinek PR middle-end/84309 * match.pd (pow(C,x) -> exp(log(C)*x)): Use exp2s and log2s instead of exps and logs in the use_exp2 case. * gcc.dg/pr84309-2.c: New test. Jakub --- gcc/match.pd.jj 2018-02-13 12:14:08.108314686 +0100 +++ gcc/match.pd 2018-02-13 12:28:59.958328523 +0100 @@ -4032,7 +4032,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* As libmvec doesn't have a vectorized exp2, defer optimizing this until after vectorization. */ (if (canonicalize_math_after_vectorization_p ()) - (exps (mult (logs @0) @1)))))))) + (exp2s (mult (log2s @0) @1)))))))) (for sqrts (SQRT) cbrts (CBRT) --- gcc/testsuite/gcc.dg/pr84309-2.c.jj 2018-02-13 12:30:25.208304990 +0100 +++ gcc/testsuite/gcc.dg/pr84309-2.c 2018-02-13 12:31:35.959285452 +0100 @@ -0,0 +1,11 @@ +/* PR middle-end/84309 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ + +double +foo (double x) +{ + return __builtin_pow (2.0, x); +} + +/* { dg-final { scan-tree-dump "__builtin_exp2 " "optimized" { target *-*-linux* *-*-gnu* } } } */