From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 04C3A3858D39 for ; Tue, 28 Mar 2023 09:23:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04C3A3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2FC65219A6; Tue, 28 Mar 2023 09:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1679995404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uOmjkWpx6lhgP2QaJyuEvaCRRp/WjdGWClBq/aU6pRo=; b=C8V+OJ+qVGPfFj/3YT1PMKGLsvpZ4iXDndnr9PfsJpMwZ4/unYZz4BnPn/RvG5gr/BnCfH LBannXLEs+l0Xsv4iTfPwHy34TclyDq5OjQ9oH+ilDEkqa/HEvR7lHpxJ4WSo6PgbSPnd1 M+p9BVBM4aXERNcazTH3mrqTs+7e5tg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1679995404; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uOmjkWpx6lhgP2QaJyuEvaCRRp/WjdGWClBq/aU6pRo=; b=VAKvUe+dOXnmVl0qa/VOM3j/0zKnDthMnkj64M07QuErOjD536U+CC5rRP+rz1cvpMFS1q ovLMR1xM1DGYyOCA== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 1FDB92C141; Tue, 28 Mar 2023 09:23:24 +0000 (UTC) Date: Tue, 28 Mar 2023 09:23:23 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] match.pd: Fix up sqrt (sqrt (x)) simplification [PR109301] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 28 Mar 2023, Jakub Jelinek wrote: > On Tue, Mar 28, 2023 at 08:57:12AM +0000, Richard Biener wrote: > > Hmm, but canonicalize_math_p () should be false after vectorization? > > > > When we moved the pass we should have made sure to put the > > PROP_gimple_opt_math property set to pass_expand_powcabs instead. > > Which pass is the one that actually canonicalizes the math such > that we want to keep its choices for later? > I must say I don't know the details why the sincos path has been > even moved. The pass was split into sincos + pass_expand_powcabs - canonicalization happens through folding and pass_expand_powcabs expands pow (x, 2) to x * x. Folding would make x * x to pow (x, 2) so it's important to set the property after pass_expand_powcabs. I think we moved sincos because vectorizing cexpi never materialized(?) but maybe I misremember. > > Now, the sqrt (sqrt ()) canonicalization to pow (.., 1./4) is > > probably invalid anyway, not sure if we can add a user-written > > vector sqrt testcase that would trigger during the canonicalization > > How do we write user written vector sqrt? I'm not sure ;) > > phase. There are other uses of build_real that have the same > > issue - what's your conclusion this is never a problem there? > > Looking through build_real* calls in match.pd, others are > either on simplifications of some expressions with REAL_CST operand > (so can't be vector then), or using > LOG*/EXP*/CBRT*/SIN*/ATAN*/COS*/POW*/CABS*/HYPOT*/POWI*/SIGNBIT* > calls in the expression being simplified, or this case. > I think no target provides vector optabs for those or they don't > have internal fns at all. > Maybe > (simplify > /* signbit(x) -> x<0 if x doesn't have signed zeros. */ > (SIGNBIT @0) > (if (!HONOR_SIGNED_ZEROS (@0)) > (convert (lt @0 { build_real (TREE_TYPE (@0), dconst0); })))) > ? Maybe. But as said, the fix is probably to move the pass property. Richard.