From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 77B7B3954470 for ; Mon, 20 Feb 2023 10:06:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 77B7B3954470 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x532.google.com with SMTP id cq23so2153089edb.1 for ; Mon, 20 Feb 2023 02:06:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=z2JZP7c1HtseTH26mRBIon8A21U+TWPxZF2dAwkqhwc=; b=HhgKhh02m++0i7ygyrlclfMOkwblyajyyWFkRAAz5iV9HJG7OuG9K1QqiT1sGWyQvc ZU4BIFWmJrkrLkIkzyCjJj/GzaybCcxQM4LeclPx95K+dylAdcKUh8GnNSice3C+6Rwl 1Yqbi4W0tF2pjYcQix3acmhHB89XxI1fZM4Y1MF2A7oG0ORH5so/UZv/g7Nv1k7UTI82 Na5k/fRuZtS+qr999fxlrUJMiSiiQzL4TYs99hazI0QRO830FtNPMuaiJR1lWSQQQGDC mUeAUhKPp/hfmCDHhtzpIr71CX0kI6G7KLsqqmsctQcyZlyHeQGdqLgZYgjJG9KkBbyy /1zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=z2JZP7c1HtseTH26mRBIon8A21U+TWPxZF2dAwkqhwc=; b=c1pTQ/VqDMQnOFG00Qf1QVyUCJR6w5u7KR7/Zu7sUkf3mXMMGZ1jZfKbPJPM5YHE7Z P7IusH6S13yz2LclXn88tRBjD6/hQhN1517WfigwuHQQYRcjCzLTZm+7vao42aGwVdEh mCqD0BYnmMhOSI/XmK8LdoGFD/X6vuqbSW7bVaC2B/IVhpN8luV0BkEu7nJXMk9En65X mS6Ljy/EjYIistiQ9nEF+Odn8t5WURsIbD0jH2D6lIZay+4ZhG5R7avVYMQ+mRkBiTsE KvqIIF/hK0LS6Kmw5sZdO4fw9k5lvQdqE1eeTJvvovXrvDeUjJBgNVxiAI7pgVGsGncU aNEw== X-Gm-Message-State: AO0yUKWBgG+mqcVcWR588B0RcllDtjZuK28Bov95CqRpi6HxjUfTvwJG fKAxG5dEd5tnGTDhJf55esI89PdanVOx5Wrj+UJwNEak X-Google-Smtp-Source: AK7set8q2kMDz5xCjELdQC0HJesS5L5C+8H2hTwWYihklCJcPd09F+Cq0JuryMM4PnpN76TJT7dNT8bSDqlDzQmdH40= X-Received: by 2002:a05:6512:1319:b0:4dd:8403:13f8 with SMTP id x25-20020a056512131900b004dd840313f8mr65380lfu.0.1676880710243; Mon, 20 Feb 2023 00:11:50 -0800 (PST) MIME-Version: 1.0 References: <26ca669c-70ce-e475-717e-3c36f1e1c703@gmail.com> In-Reply-To: From: Richard Biener Date: Mon, 20 Feb 2023 09:11:37 +0100 Message-ID: Subject: Re: RISC-V: Add divmod instruction support To: "Maciej W. Rozycki" Cc: Jeff Law , Andrew Pinski , Palmer Dabbelt , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=unavailable 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 Sun, Feb 19, 2023 at 2:15 AM Maciej W. Rozycki wrote: > > On Sat, 18 Feb 2023, Jeff Law wrote: > > > > Barring the fusion case, which indeed asks for a dedicated `divmod' > > > pattern (and then I suppose a post-reload splitter or a peephole so that > > > where one of the two results produced has eventually turned out unused, we > > > have means to discard the unneeded machine instruction), isn't the generic > > > transformation something for the middle end to do based on RTX costs? > > I originally though the same way you did Maciej. > > > > The problem is you don't see it as a divmod in expand_divmod unless you expose > > a divmod optab. See tree-ssa-mathopts.cc's divmod handling. > > That's the kind of stuff I'd expect to happen at the tree level though, > before expand. The GIMPLE pass forming divmod could indeed choose to emit the div + mul/sub sequence instead if an actual divmod pattern isn't available. It could even generate some fake mul/sub/mod RTXen to cost the two variants against each other but I seriously doubt any uarch that implements division/modulo has a slower mul/sub. Richard. > > Maciej