From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 8B8973858D28 for ; Sun, 26 May 2024 14:40:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B8973858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8B8973858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716734411; cv=none; b=aVxew2wZre+ldyPPC1VyE2+hvvJ3ySF+CvBT60EP3VqwW0D0ufBR4I53Qd6Rf4d/j6lsM7e3cTnrrV3A1Q0ONzzQBYtQml6KMz5cuuxc9m1V6VccscZhF53zUqOtRL8fGRdt1tk+QWtRxMydXQaUVp/SgbKtX+S85PWwEd67B5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716734411; c=relaxed/simple; bh=O8530GUAFu669FSD7qoqEzqDoNm2O/kf0xXW3SC0ZVc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Mmq9n9J0CTPQpF6z0loTIMlGCn5bf9waA8Ie0YgBsCCu7p7EJG03VmiBrrKXgZSsQXE8PulRjfSzWEd0V0XnRROYz3M0ox9jfhNg+Vj45saPZMmB4qhmsXMFZancQVC+H/ut8Z3MPgxM3ADW01QVst7W2lmmWqmo2DR6lJjtLIA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6f8e9870e72so2166012b3a.1 for ; Sun, 26 May 2024 07:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716734408; x=1717339208; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=X/UxKeB3uZQ6gyHD2ps3c7MlqjtPKF5zBq8UEDm6Q+4=; b=f6r6oCFX4M8zciM25KO9IDKwR+gF83laYS8AYK+W0y1xTfILaM8QpEBiBSw24tTbst BKmIsjKggCNaT/pW1/3KvKONAlkuHKfXAAUG93Hi7Nqi9GAF/5aToCkysO0o8yHhcEoF mq43ZjqbKm5DAc6MB8eXLcJtHeT/ZsEqYXILPfOFviqUNZNSr5BH0LyJpqFgPgEF6g4X AqesbT0HUf2XykOIZNiuMxIOzf+pT8Ha92lWYQMmeSTplNb/D4bAq4k/fDlKugOL8vOq 7ftGiQAgovgtKJb/rABbJFUr4632qc0pGe6uUEsWw/trZxVS5IIWbTZCGd9nRmvHJKI2 4gUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716734408; x=1717339208; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X/UxKeB3uZQ6gyHD2ps3c7MlqjtPKF5zBq8UEDm6Q+4=; b=S+6IRT2jj6zzHHq60YOiRs6M7VpDU9VAKeLD+3JnMTFw2iikbKYAuSDcIvP2T2b9JR 9cXi/Tomx2Wmt2mC6VEMArILDCxc8Of8mKBrLPS4JDPX89kpgtlD4bZEYRSd0vFoR+8O HlPE5TNhCftlBO2RvI8jiLh48+PavG8uCelcliPIec5cPxMlvxF3WbMzCh/CEq+kgVeF X+2/CKhNm+i+O8fiiv9wLxVs2+gMxSnfBkabD9WTT/LqWDGGcmHD2zlWvomlY99F5a9M cCBI7mSUVE3u7FHuwBoS6/owQqa0XgH9AGDpqbqHKYzwisqNj0KONqtXaq6u3WS+nJkp oN8g== X-Forwarded-Encrypted: i=1; AJvYcCX6Aa7hflZOLF3v0hHuAXTUjTqKnqyXVFEQLULEu4/AiQDchXWnFJDa7/UlYwkznezQ68eqxuF7M/dT1PiYaCIsLfXx7Z+tUg== X-Gm-Message-State: AOJu0Yw14tp8z/Qh1ECSoo+CjvO5dS4+nabYpHX4U5UIlFE2XgU4uJ9A lkwKoZ15TebXcbtykZnStlVjB8/UgMdgDEDiUAEttHlbevxEcihrZlAGzjia X-Google-Smtp-Source: AGHT+IHmmuGon9CmU+CwF0G34yPMHtl4RhfVLD0IKOTqCxkDeoPf6ERUtG0TTahvLm9MMZ/Syg27nw== X-Received: by 2002:a05:6a20:7352:b0:1b0:25b6:a78b with SMTP id adf61e73a8af0-1b212e02f56mr8886317637.49.1716734407889; Sun, 26 May 2024 07:40:07 -0700 (PDT) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f8fd2d32e5sm3659737b3a.177.2024.05.26.07.40.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 May 2024 07:40:07 -0700 (PDT) Message-ID: Date: Sun, 26 May 2024 08:40:06 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH] gimple-vr-values:Add constraint for gimple-cond optimization Content-Language: en-US To: Feng Wang , gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com References: <20231123054758.28829-1-wangfeng@eswincomputing.com> From: Jeff Law In-Reply-To: <20231123054758.28829-1-wangfeng@eswincomputing.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 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,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 11/22/23 10:47 PM, Feng Wang wrote: > This patch add another condition for gimple-cond optimization. Refer to > the following test case. > int foo1 (int data, int res) > { > res = data & 0xf; > res |= res << 4; > if (res < 0x22) > return 0x22; > return res; > } > with the compilation flag "-march=rv64gc_zba_zbb -mabi=lp64d -O2", > before this patch the compilation result is > foo1: > andi a0,a0,15 > slliw a5,a0,4 > addw a3,a5,a0 > li a4,33 > add a0,a5,a0 > bleu a3,a4,.L5 > ret > .L5: > li a0,34 > ret > after this patch the compilation result is > foo1: > andi a0,a0,15 > slliw a5,a0,4 > add a5,a5,a0 > li a0,34 > max a0,a5,a0 > ret > The reason is in the pass_early_vrp, the arg0 of gimple_cond > is replaced,but the PHI node still use the arg0. > The some of evrp pass logs are as follows > gimple_assign > gimple_assign > gimple_cond > goto ; [INV] > else > goto ; [INV] > > : > // predicted unlikely by early return (on trees) predictor. > > : > # gimple_phi <_2, 34(3), res_5(2)> > The arg0 of gimple_cond is replaced by _9,but the gimple_phi still > uses res_5,it will cause optimization fail of PHI node to MAX_EXPR. > So the next_use_is_phi is added to control the replacement. > > gcc/ChangeLog: > > * vr-values.cc (next_use_is_phi): > (simplify_using_ranges::simplify_casted_compare): > add new function next_use_is_phi to control the replacement. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/zbb-min-max-04.c: New test. I'm not sure what changed, but AFAICT this patch isn't needed anymore. We get the desired code with the trunk compiler. Jeff