From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by sourceware.org (Postfix) with ESMTPS id 9BD363882150 for ; Fri, 16 Sep 2022 06:47:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9BD363882150 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-yw1-x112f.google.com with SMTP id 00721157ae682-333a4a5d495so248329537b3.10 for ; Thu, 15 Sep 2022 23:47:38 -0700 (PDT) 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; bh=/DGHj+0IwrL8+cj2hyKju7Ecf+IJmNHpP/JM+cWY1EE=; b=CxPRIciMi1O+jBu9B+MrtAHH5AKBbAH6Pleop/8TTKLa8DjsVZ/DYypNRH1KBdJx1C +JltArfQw3fYFqb4BJ0hrvjDir59u7K47PFj8qtRzs+xPSeNgerqCK5ySuQMK377QP+L N8tr0zkMzg5tYDxSOfSQY7vRqDTaBkAJDZFSaMRWm7TAP6tHeBaQUOGoXadvbfELhCV3 n33dCKc/Kg93a79WwYecEY7RevhRfHcueRhwaWjcYiWQna4Wp6D0NnoDLFsXQFtG/6WD nJQydDc9DL7ESfDv07/hA3Exb6LCJ07tQBLHZ3cZGyjdcTNwmNHLuvfOw4FU/3Pufb30 hr5g== 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; bh=/DGHj+0IwrL8+cj2hyKju7Ecf+IJmNHpP/JM+cWY1EE=; b=mCWNiZDRKFyc86v6EXOW2yuMwkOVwvVipCV90fOihn+5mhXTA20tJp2ybf7LeVU9bL Aelzam57+J43mnMrByffpgqFHEYee19EkQRSXfIbRdcxU0+nRr+5lt4d+DC+a8+et4q7 Xbd/BEgnBrM5TBiGXtpnikjA/cbs+wSpylSqVJ/uHOwVDxhsvdjySeUjqp3XovD31vBH Ye275GsUgVbvbuJIKb5SmuO4X0qdXb2q0Tptk2GpMtPoHF0XUmR4IhhdH2+z0/kWhGWh oaAGCEmykujpfX53u8MQRAzNEiYeKjDyV95GsJT2UtfeZmeYpZnuyFwpaZFhUDl98o4x cJ1Q== X-Gm-Message-State: ACrzQf0XVzRJWM/fT2JUn+l2WR1DDOIPkfZ3qYToEWO0PTVx87wCXuX2 y5fq1JICFZTcat4q13FkSMw4Oc9r73KdGYCPd78= X-Google-Smtp-Source: AMsMyM7cZ6nvFocs1HqZRclbTU8MG6wPQyPVYwfWE1BvewGQAcD+0vqlS2buPYCiyxybt1bcyXtwBt8U3CRUsHf91is= X-Received: by 2002:a81:60c6:0:b0:345:7a55:20ce with SMTP id u189-20020a8160c6000000b003457a5520cemr3171834ywb.480.1663310857902; Thu, 15 Sep 2022 23:47:37 -0700 (PDT) MIME-Version: 1.0 References: <20220916010659.37555-1-hongtao.liu@intel.com> <261569e3-d4e9-5b64-b97d-8120b49b92a9@gmail.com> In-Reply-To: <261569e3-d4e9-5b64-b97d-8120b49b92a9@gmail.com> From: Uros Bizjak Date: Fri, 16 Sep 2022 08:47:26 +0200 Message-ID: Subject: Re: [PATCH] [x86]Don't optimize cmp mem, 0 to load mem, reg + test reg, reg To: Jeff Law Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,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 Fri, Sep 16, 2022 at 3:32 AM Jeff Law via Gcc-patches wrote: > > > On 9/15/22 19:06, liuhongt via Gcc-patches wrote: > > There's peephole2 submit in 1990s which split cmp mem, 0 to load mem, > > reg + test reg, reg. I don't know exact reason why gcc do this. > > > > For latest x86 processors, ciscization should help processor frontend > > also codesize, for processor backend, they should be the same(has same > > uops). > > > > So the patch deleted the peephole2, and also modify another splitter to > > generate more cmp mem, 0 for 32-bit target. > > > > It will help instruction fetch. > > > > for minmax-1.c minmax-2.c minmax-10, pr96891.c, it's supposed to scan there's no > > comparison to 1 or -1, so adjust the testcase since under 32-bit > > target, we now generate cmp mem, 0 instead of load + test. > > > > Similar for pr78035.c. > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,} > > No performance impact for SPEC2017 on ICX/Znver3. > > > > Ok for trunk? > > > > gcc/ChangeLog: > > > > * config/i386/i386.md (*3_1): Replace > > register_operand with nonimmediate_operand for operand 1. Also > > force_reg it when mode is QImode. > > (define_peephole2): Deleted related peephole2. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/i386/minmax-1.c: Scan-assemble-not for cmp with 1 > > or -1, also don't scan-assembler test for ia32. > > * gcc.target/i386/minmax-10.c: Ditto. > > * gcc.target/i386/minmax-2.c: Ditto. > > * gcc.target/i386/pr78035.c: Ditto. > > * gcc.target/i386/pr96861.c: Scan either cmp or test 3 times. > > It was almost certainly for PPro/P2 given it was rth's work from > 1999. Probably should have been conditionalized on PPro/P2 at the > time. No worries losing it now... Please add a tune flag in x86-tune.def under "Historical relics" and use it in the relevant peephole2 instead of deleting it. Uros.