From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117654 invoked by alias); 10 Nov 2015 10:21:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 117641 invoked by uid 89); 10 Nov 2015 10:21:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f176.google.com Received: from mail-yk0-f176.google.com (HELO mail-yk0-f176.google.com) (209.85.160.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 10 Nov 2015 10:21:24 +0000 Received: by ykdv3 with SMTP id v3so215707725ykd.0 for ; Tue, 10 Nov 2015 02:21:22 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.129.125.137 with SMTP id y131mr2141166ywc.5.1447150882436; Tue, 10 Nov 2015 02:21:22 -0800 (PST) Received: by 10.37.93.11 with HTTP; Tue, 10 Nov 2015 02:21:22 -0800 (PST) In-Reply-To: <87egfznnxc.fsf@e105548-lin.cambridge.arm.com> References: <87io5bno02.fsf@e105548-lin.cambridge.arm.com> <87egfznnxc.fsf@e105548-lin.cambridge.arm.com> Date: Tue, 10 Nov 2015 10:21:00 -0000 Message-ID: Subject: Re: [PATCH 1/6] Use IFN_SQRT in tree-vect-patterns.c From: Richard Biener To: GCC Patches , richard.sandiford@arm.com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg01173.txt.bz2 On Mon, Nov 9, 2015 at 5:21 PM, Richard Sandiford wrote: > In practice all targets that can vectorise sqrt define the appropriate > sqrt2 optab. The only case where this isn't immediately obvious > is the libmass support in rs6000.c, but Mike Meissner said that it shouldn't > be exercised for sqrt. > > This patch therefore uses the internal function interface instead of > going via the target hook. > > > gcc/ > * tree-vect-patterns.c: Include internal-fn.h. > (vect_recog_pow_pattern): Use IFN_SQRT instead of BUILT_IN_SQRT*. > > diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c > index bab9a4f..a803e8c 100644 > --- a/gcc/tree-vect-patterns.c > +++ b/gcc/tree-vect-patterns.c > @@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see > #include "tree-vectorizer.h" > #include "dumpfile.h" > #include "builtins.h" > +#include "internal-fn.h" > #include "case-cfn-macros.h" > > /* Pattern recognition functions */ > @@ -1052,18 +1053,13 @@ vect_recog_pow_pattern (vec *stmts, tree *type_in, > if (TREE_CODE (exp) == REAL_CST > && real_equal (&TREE_REAL_CST (exp), &dconsthalf)) > { > - tree newfn = mathfn_built_in (TREE_TYPE (base), BUILT_IN_SQRT); > *type_in = get_vectype_for_scalar_type (TREE_TYPE (base)); > - if (*type_in) > + if (*type_in && direct_internal_fn_supported_p (IFN_SQRT, *type_in)) > { > - gcall *stmt = gimple_build_call (newfn, 1, base); > - if (vectorizable_function (stmt, *type_in, *type_in) > - != NULL_TREE) > - { > - var = vect_recog_temp_ssa_var (TREE_TYPE (base), stmt); > - gimple_call_set_lhs (stmt, var); > - return stmt; > - } > + gcall *stmt = gimple_build_call_internal (IFN_SQRT, 1, base); > + var = vect_recog_temp_ssa_var (TREE_TYPE (base), stmt); > + gimple_call_set_lhs (stmt, var); > + return stmt; Looks ok but I wonder if this is dead code with (for pows (POW) sqrts (SQRT) cbrts (CBRT) (simplify (pows @0 REAL_CST@1) (with { const REAL_VALUE_TYPE *value = TREE_REAL_CST_PTR (@1); REAL_VALUE_TYPE tmp; } (switch ... /* pow(x,0.5) -> sqrt(x). */ (if (flag_unsafe_math_optimizations && canonicalize_math_p () && real_equal (value, &dconsthalf)) (sqrts @0)) also wondering here about canonicalize_math_p (), I'd expected the reverse transform as canonicalization. Also wondering about flag_unsafe_math_optimizations (missing from the vectorizer pattern). Anyway, patch is ok. Thanks, Richard. > } > } > >