From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by sourceware.org (Postfix) with ESMTPS id 03CB23856DF0 for ; Mon, 23 May 2022 08:21:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 03CB23856DF0 Received: by mail-qv1-xf33.google.com with SMTP id e17so11606159qvj.11 for ; Mon, 23 May 2022 01:21:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/fKD/wsZQo7LuH+A+zbbGXyQNG3EQCfNahPuv6a1lUM=; b=DkJ1FjQGZQHwEBv1qvtm+0MOlyjSeUzZxYKniWYy73Q3LprfuBw9O6rdjb3YWKf5G9 ZCVsq1Uf7k/3wyx/6dURE6TYkQCHePnW7RP7dSektZfHikZLrvXjdm9w3C+rAxXSnwut P7VufcpWUVGQlR83slRc8TtEWkBbOOWSyFQNCd6+grK9qzJNjWfnyj1JMMBxt/Vq47Fa FTeLAN2OUWn2Rtw7s0PJFxkQMiedauipFoojcyk4UwCxo+cZrBKoZRijcpwKTfmisu1F U1/FNNGNPgdGnXJRLB9yHDSn48a9a+VlLbq7GNBpfdplO+/VhqFAIe2ja07zyNn1KCbD KuDw== X-Gm-Message-State: AOAM533szIgxun9LGfcSuHFi/YCIfsAl7Rnh5Es48ZqH7jrb2t3uyO9i /D5Zftr52mYRvj2b3kKy9pu3jFLMCw+gR3DfhLEp2Rtr X-Google-Smtp-Source: ABdhPJw2x/swTJ6z/vaSTKYwnqt0mPhjwMS/n739z0gwDi7iobnxvistvVP+SulLSIRy9mSm/qqcEWDRO1iHgVY4t3Y= X-Received: by 2002:a05:6214:3e1:b0:461:f0b1:6b12 with SMTP id cf1-20020a05621403e100b00461f0b16b12mr16217919qvb.122.1653294080409; Mon, 23 May 2022 01:21:20 -0700 (PDT) MIME-Version: 1.0 References: <020b01d86dba$b2e29cd0$18a7d670$@nextmovesoftware.com> In-Reply-To: <020b01d86dba$b2e29cd0$18a7d670$@nextmovesoftware.com> From: Richard Biener Date: Mon, 23 May 2022 10:21:09 +0200 Message-ID: Subject: Re: [PATCH] Minor improvement to genpreds.cc To: Roger Sayle Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.7 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, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2022 08:21:22 -0000 On Sun, May 22, 2022 at 11:03 AM Roger Sayle wrote: > > > This simple patch implements Richard Biener's suggestion in comment #6 > of PR tree-optimization/52171 (from February 2013) that the insn-preds > code generated by genpreds can avoid using strncmp when matching constant > strings of length one. > > The effect of this patch is best explained by the diff of insn-preds.cc: > < if (!strncmp (str + 1, "g", 1)) > --- > > if (str[1] == 'g') > 3104c3104 > < if (!strncmp (str + 1, "m", 1)) > --- > > if (str[1] == 'm') > 3106c3106 > < if (!strncmp (str + 1, "c", 1)) > --- > > if (str[1] == 'c') > ... > > The equivalent optimization is performed by GCC (but perhaps not by the > host compiler), but generating simpler/smaller code may encourage further > optimizations (such as use of a switch statement). > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check with no new failures. Ok for mainline? OK. Richard. > > 2022-05-22 Roger Sayle > > gcc/ChangeLog > * genpreds.cc (write_lookup_constraint_1): Avoid generating a call > to strncmp for strings of length one. > > Roger > -- >