From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by sourceware.org (Postfix) with ESMTPS id CE20D3858C53 for ; Thu, 18 Jan 2024 03:30:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE20D3858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dabbelt.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CE20D3858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b31 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705548653; cv=none; b=DgGmG6HjHXV9w52hdepHVfQ4OCelKHQ2RdX5u4DDBPcdqgGZYSH1yrq4ONRuUdbz7XhXLx+AsqbZcbnLBesT4hWcuVjHMGBnHsyCizeMvBxPSpztCauDHzmancvgAXGsnO6GbBP5A7aePh0qxB8gBJiLveC+bjJDaCm/icXTqdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705548653; c=relaxed/simple; bh=Pi0NSDbonOn4ZupFnoPOuCfO9ZJsiiEa6/KvEBhtFL0=; h=DKIM-Signature:Date:Subject:From:To:Message-ID:Mime-Version; b=RValCyidD3XrFYOfDr1q2VQm4CrFSIhFTSzy3tpKqlvGRlkFChYIA65uJs/UfenmQDWqyE1UWgQ+p7MFPsm0upjHWUXbPhKoYZIGhugNmqckYF8qCUEVBij4z1nyw6vP99kSBE9xQpEltm34CtiQfcWx5iwqbx9AGU9KgWi1RWI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-dc23bf7e5aaso1468493276.0 for ; Wed, 17 Jan 2024 19:30:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20230601.gappssmtp.com; s=20230601; t=1705548651; x=1706153451; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=z7J8Ysn/KDKialQBSbtxEgpBHPgM27aVTP+OY99f+D4=; b=0EvlnYHh8I/zFwt6fexUuq2KtI0m/ZSBz8gXRIWKJl5Mk7vpNWrhsn5jA7BO+wNnpO LkwOdQ9zA9+KfvYrYYcJOaYltkpbFnIEwT2p2Qig8j7+aTnlcTL/xRQiBAi9M3b2ZuTU BtN9WOj29snQCIStiW9sXJ4N9/xj/EhkmS/tCEJ8NDI6RPeLHEfPo1hlZjSzyX5Khe6u +RhqLM7y9fTjrciyaX9qhEctwu/HNZwAKW9yQg7/EuGzn+ksvAcONlaaYVM/1FaxjB6A LYj7tb4DEYhhFoCte0LPRJGv7xboWksFyc72mpFy/BOwCdxhnSZoGraJy7xKKIOGszJ/ SIig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705548651; x=1706153451; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=z7J8Ysn/KDKialQBSbtxEgpBHPgM27aVTP+OY99f+D4=; b=ftisQRUjp4ne0oik69ixllZj/3VjhVXeLBGi/bjL86psUhxaiO0FE1Yk0NqnDZpdW+ o6uM8fxalNV7rMIL7l2CGJnPIx3b7VseeTHE0J2hPco3EnbXB3g7cSKDteX7s1iENOWY Wj1tYgEUKS5dbuBJSPRzNZR6zIcgA+hzkILamyi1O4nHvtTjZOHza6jfBzdXL7f+cBtd SPJZUEtRgtmRLrgzb04J2Z5BC8iSsEmTP5XaxoRe9WrAZg/d9xQruDOMTLHAVFfHDUCQ pZj9h97BodXspg0IutuigtkV4/kaAsynGwzwBKEEEwsqBAxynIMIYDj9ruJer/oGvfCH O5nw== X-Gm-Message-State: AOJu0YzvBa4RLr27Gxx6LrUI1om9Fh2cJxUJ5XACx3sgkGE1QzjQEMbI yzOdWX7TW3yWR2gvp5zCJdlhz/aSixSu7TdRO7fkfxn5vJNLJStTRp4NMc6CCO8= X-Google-Smtp-Source: AGHT+IE7+IctoH+elagZgDPKYsCgKnQ9ino89T57c6Ln5g0ElMk5CLAd9NrPqkqXTPRC84OcPbUWvw== X-Received: by 2002:a05:6902:218d:b0:dbe:a8e7:a6ea with SMTP id dl13-20020a056902218d00b00dbea8e7a6eamr196950ybb.22.1705548651018; Wed, 17 Jan 2024 19:30:51 -0800 (PST) Received: from localhost ([192.184.165.199]) by smtp.gmail.com with ESMTPSA id l185-20020a6325c2000000b0056606274e54sm434267pgl.31.2024.01.17.19.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 19:30:50 -0800 (PST) Date: Wed, 17 Jan 2024 19:30:50 -0800 (PST) X-Google-Original-Date: Wed, 17 Jan 2024 19:30:48 PST (-0800) Subject: Re: [PATCH] match: Do not select to branchless expression when target has movcc pattern [PR113095] In-Reply-To: CC: jeffreyalaw@gmail.com, rguenther@suse.de, gcc-patches@gcc.gnu.org, apinski@marvell.com From: Palmer Dabbelt To: monk.chiang@sifive.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,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 Wed, 17 Jan 2024 19:19:58 PST (-0800), monk.chiang@sifive.com wrote: > Thanks for your advice!! I agree it should be fixed in the RISC-V backend > when expansion. > > > On Wed, Jan 17, 2024 at 10:37 PM Jeff Law wrote: > >> >> >> On 1/17/24 05:14, Richard Biener wrote: >> > On Wed, 17 Jan 2024, Monk Chiang wrote: >> > >> >> This allows the backend to generate movcc instructions, if target >> >> machine has movcc pattern. >> >> >> >> branchless-cond.c needs to be updated since some target machines have >> >> conditional move instructions, and the experssion will not change to >> >> branchless expression. >> > >> > While I agree this pattern should possibly be applied during RTL >> > expansion or instruction selection on x86 which also has movcc >> > the multiplication is cheaper. So I don't think this isn't the way to >> go. >> > >> > I'd rather revert the change than trying to "fix" it this way? >> WRT reverting -- the patch in question's sole purpose was to enable >> branchless sequences for that very same code. Reverting would regress >> performance on a variety of micro-architectures. IIUC, the issue is >> that the SiFive part in question has a fusion which allows it to do the >> branchy sequence cheaply. >> >> ISTM this really needs to be addressed during expansion and most likely >> with a RISC-V target twiddle for the micro-archs which have >> short-forward-branch optimizations. IIRC I ran into some of these middle-end interactions a year or two ago and determined that we'd need middle-end changes to get this working smoothly -- essentially replacing the expander checks for a MOVCC insn with some sort of costing. Without that, we're just going to end up with some missed optimizations that favor one way or the other. >> >> jeff >>