From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by sourceware.org (Postfix) with ESMTPS id 618233858D1E for ; Sun, 1 Jan 2023 18:23:11 +0000 (GMT) Received: by mail-vs1-xe2b.google.com with SMTP id x65so13174507vsb.13 for ; Sun, 01 Jan 2023 10:23:11 -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=uekf5TcVHZN2HtAMMnWhtQVUvZbh15vmpaM8WZ5ixPs=; b=iTGBX1k5Hjwob0BIFH9HF6pdBzvF6XNgjBG2qx0BAzFJsIpKWuaV2RoiGYiOwnruXJ ml+KalYDtLHir9clddcFxnBxWdjfLfMj8dS5L0kOflynbNvvAaxE3knBadg2a0/yH+Gt RjcAmiqOD5dAmxMabEjePKIH6j6+WA/+oufbt2/lKzwVlje1TLNwlsMjb9ZqVZIpiTbA K4SDy8+zrChaTUhk6NwHmxQ2vzqOXa10wLYDPjLDJZoHv+rPuCTAe9B8hn4ABOCMMohi 1esGQZeU8oCgVPXN/dgPDd9yS6Qdasw/Ujr8fntCPmB3kZbSBI11GkSZwMfVWJ89bNlw Uf6w== 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=uekf5TcVHZN2HtAMMnWhtQVUvZbh15vmpaM8WZ5ixPs=; b=FHC3g0aYf9mj8EFAJwJZn69eYfINmi1vOkGhIwRaHe2XTdeHsk7B5S5Ptjbj/C8s11 aSU3fLMGM2wjt2IdaIKkJByJW2SsQbesGRO63fS+mEj33xrJUP2Ybc8Wj7I3nx7HoU4A +72cBh3tQolhUqU7nI4BroP54auXJrXIIxlvPprir3xenfY/mves2PNs31YBpZi4QsNA b8+YSUE9AcSWUVdtKX8rkrhfRZnXxZLaJPYKItccSx5NuZ6cewSWiZWLinwx7sm/oqGP Uj2xvWJIQurG+Tf3GIS2zUwypqYZFuxCikhJf7EpqV9josH9h18lRsBkahNS21K3qznQ IDzw== X-Gm-Message-State: AFqh2kou0T+j4aDZfGVBOSp95Yh9s9uDZrz3ON/FdnUeMuxnv+K9IqZY Tem4enN05PvYvyFIv7pH9Cn10hvEvAD37IfaniI= X-Google-Smtp-Source: AMrXdXtDW5E8er322VEyJxj/6sLw7AZYeWIJbmSASgxSNBJC5JYFdIPwoZ1czT1VZQvmq3dmm/Y6g56yAYd0J2/s9h8= X-Received: by 2002:a67:ea55:0:b0:3b5:2494:c23 with SMTP id r21-20020a67ea55000000b003b524940c23mr4415348vso.29.1672597390664; Sun, 01 Jan 2023 10:23:10 -0800 (PST) MIME-Version: 1.0 References: <005a01d91e01$80bd4af0$8237e0d0$@nextmovesoftware.com> In-Reply-To: <005a01d91e01$80bd4af0$8237e0d0$@nextmovesoftware.com> From: Uros Bizjak Date: Sun, 1 Jan 2023 19:22:59 +0100 Message-ID: Subject: Re: [x86 PATCH] PR target/108229: A minor STV compute_convert_gain tweak. To: Roger Sayle Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.2 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=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 Sun, Jan 1, 2023 at 5:53 PM Roger Sayle wrote: > > > This patch addresses PR target/108229, which is a change in code > generation during the STV pass, due to the recently approved patch > to handle vec_select (reductions) in the vector unit. The recent > change is innocent, but exposes a latent STV "gain" calculation issue > that is benign (or closely balanced) on most microarchitectures. > > The issue is when STV considers converting PLUS with a MEM operand. > > On TARGET_64BIT (m=1): > addq 24(%rdi), %rdx // 4 bytes > or with -m32 (m=2) > addl 24(%esi), %eax // 3 bytes > adcl 28(%esi), %edx // 3 bytes > is being converted by STV to > vmovq 24(%rdi), %xmm5 // 5 bytes > vpaddq %xmm5, %xmm4, %xmm4 // 4 bytes > > The current code in general_scalar_chain::compute_convert_gain > considers that scalar unit addition is replaced with a vector > unit addition (usually about the same cost), but doesn't consider > anything special about MEM operands, assuming that a scalar load > gains/costs nothing compared to a vector load. We can allow the > backend slightly better fine tuning by including in the gain > calculation that m scalar loads are being replaced by one vector > load, and when optimizing for size including that we're increasing > code size (e.g. an extra vmovq instruction for a MEM operand). > > This patch is a win on the CSiBE benchmark when compiled with -Os. > Alas I've no new testcase as this is extremely sensitive to the > backend microarchitecture parameterization (and it's dangerous to > select parameters from the N=1 statistics of a single bugzilla PR). > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check, both with and without --target_board=unix{-m32}, > with no new failures. Ok for mainline? > > > 2023-01-01 Roger Sayle > > gcc/ChangeLog > PR target/108229 > * config/i386/i386-features.cc > (general_scalar_chain::compute_convert_gain) : Consider > the gain/cost of converting a MEM operand. LGTM. Thanks, Uros. > > Thanks in advance, > Roger > -- >