From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 058043858D35; Wed, 15 Nov 2023 11:44:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 058043858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 058043858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700048685; cv=none; b=cU26XhYJQUoBY1ZkDhbutB8UkhNsNZQKGeW+yuMbqqy7UKLhvRBo9UXk7/V5Tpb8WFVxfxxuNr56l251qG7Y0hZ2EfTxqOofVYal8yuUw/f9kVxFi0VeSvyHflQ1aAw6/pmyolRQXccPGq6wg6s0MEPy8TocvH3rjv0UIUUE5Ds= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700048685; c=relaxed/simple; bh=T9QPF1WaQIOvuo5ti10UQ4ESg/IMZpzbPn1VgBqWgtA=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=x+lMTPAwSWA+Ocq5/6xIFfM4OaVUqyqvMplXoZ99zF8SXhdSZAEhlEYRG8ee9Qzaum1DRlsjs3vpWXA0O1sojju7C6KDwQi3IHdNyLMva5KlgUwdiGEXTP7aimSnzU5olBoVKv2A39chcPW6knIJqULYZ24QfKzNDt9fPhP5MPA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-507a5f2193bso822297e87.1; Wed, 15 Nov 2023 03:44:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700048682; x=1700653482; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OX9ir/sZ3dcWWU1B+mcmphloWyy4PnfcSuIsuBjti7E=; b=UWG2QfJZRhymtsqaK62NO/xxpXqR037IlyZEwX1sBHVRWf1J7Dfi0xhwaN+x3KW7jx btoEY/Z/na8Yan9j80LDeA/girL97bLQ0js1xofgK8BLDi478OwJgU+iaopLz251V7gP FkCTWdoHmRz15BAu4cuBo9plDlbuAQsF6/ZZdUEXpk/nKDxetD0JcWuu0uYnT+Bmu5Xg JDRtH4lLxr/EGq6/A0F8itnfYUSsQLQoOcAsxNz20QIbR3pTv7Bd5tUT9xfRmBOZANkA 2a6BiBmHx9MbY/pBoOud/o3smy/FCcos+w7VTEWdJ30JgUvgI6qFvhbPqg4hpouhkY9y caeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700048682; x=1700653482; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OX9ir/sZ3dcWWU1B+mcmphloWyy4PnfcSuIsuBjti7E=; b=XDX2hm4ndVipkBs9Y09NLpGeqHkUwQcQxoqqaT7xap1veKPmodBVHDWRGMRHa1PyhG J9o2zxkYfNP1UHW7g5UkkVvUdCDnfsH+yRYTnGZhwijaSkpfbJWfzp6uQnPOo94FtQBq I7/kkHxiNwy5pSETH41l43/sMnKP1ftLqcfHKMZoZp+VAfeSgVOtAq7l2RVDzayXTGhM VLrd9hw5CCXXnkET/ZppRX4c5OPylLp6HzNqywJkymW6k8c2aTxf4rjQZNgPGykHkqSI 5a/4lRnPS2wJ7Hd1+fMh8oEqLEPXeUmCvKhpwzKEHhbqgPDm55Nbs4+VrMF3zBS4qF7F 3XUA== X-Gm-Message-State: AOJu0Yzi2Jssr/ToRIhFgQH9gmYtdlr3d8S3+QwEqJZdGE20GrnL5+l+ xZ0VklHqBmjoG2LIaQUYVdcJaE3ieTtP9mzXKjM= X-Google-Smtp-Source: AGHT+IHX9hCDQ+vhIwQ3Gr1SehdaWvRt1rnJZXdJfKEBsZBrpBbVbJAe9oA7CfIZBWq7VIQajWB3nN3L8dlqIBdoAnY= X-Received: by 2002:a05:6512:234e:b0:509:8def:e8b with SMTP id p14-20020a056512234e00b005098def0e8bmr2432609lfu.0.1700048682102; Wed, 15 Nov 2023 03:44:42 -0800 (PST) MIME-Version: 1.0 References: <20231114100320.47373-1-xry111@xry111.site> In-Reply-To: From: Richard Biener Date: Wed, 15 Nov 2023 12:41:10 +0100 Message-ID: Subject: Re: [PATCH] Only allow (copysign x, NEG_CONST) -> (fneg (fabs x)) simplification for constant folding [PR112483] To: Xi Ruoyao Cc: gcc-patches@gcc.gnu.org, chenglulu , i@xen0n.name, xuchenghua@loongson.cn, Tamar Christina , tschwinge@gcc.gnu.org, Roger Sayle , Andrew Pinski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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, Nov 14, 2023 at 10:14=E2=80=AFPM Xi Ruoyao wro= te: > > On Tue, 2023-11-14 at 11:44 +0100, Richard Biener wrote: > > > diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc > > > index 2d2e5a3c1ca..f3745d86aea 100644 > > > --- a/gcc/simplify-rtx.cc > > > +++ b/gcc/simplify-rtx.cc > > > @@ -4392,7 +4392,7 @@ simplify_ashift: > > > real_convert (&f1, mode, CONST_DOUBLE_REAL_VALUE (trueop1)= ); > > > rtx tmp =3D simplify_gen_unary (ABS, mode, op0, mode); > > > if (REAL_VALUE_NEGATIVE (f1)) > > > - tmp =3D simplify_gen_unary (NEG, mode, tmp, mode); > > > + tmp =3D simplify_unary_operation (NEG, mode, tmp, mode); > > > return tmp; > > > } > > > > shouldn't that be when either the ABS or the NEG simplify? > > Simplify (copysign x, POSTIVE_CONST) to (abs x) is an optimization. So > for a positive f1, tmp will just be (abs x) and we return it. Ah, OK. > > And I wonder when that happens - I suppose when op0 is CONST_DOUBLE onl= y? > > Yes, it's Andrew's intention. The patch is fine then. Richard. > -- > Xi Ruoyao > School of Aerospace Science and Technology, Xidian University