From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 9E4933858D32 for ; Tue, 5 Sep 2023 06:06:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E4933858D32 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-pl1-x62e.google.com with SMTP id d9443c01a7336-1c1e128135aso12036115ad.3 for ; Mon, 04 Sep 2023 23:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693893967; x=1694498767; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=dyY86mwMghwNrmBLhy6KRaCaNt8tmfnqGUthh0BBXY8=; b=d+BFL7Ug4EJq2/hEEtNhLoipAf6euXutrebbeDZ6/bzwIqDj3soPdWz+DjnU04r1/3 /+SnzqwIUCchOX+MRUQlMtCUcOhnmB7L008ihGRIpdyKgEPkzsQ0843qB91IRjYXZKT2 f5d18vrH5+VaPvBBXKZvhxX1sng517hLuONGRZqbs/W/NG2/gqGaNHwpdkpFw5FQvd99 j5giO+c2rtpdSSTe+537wpbGB0zbA1xoydiCEo94/sc3EEfQCUI9DkuPeH+I3SrjlShC Cz8hGIC8fl+BIrvFs0Gplcf0/zFCMFhX4WFULFG/qrMbAaafhuSTo5joMVDU9LnSehOQ zgdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693893967; x=1694498767; h=content-transfer-encoding:in-reply-to:from:references: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=dyY86mwMghwNrmBLhy6KRaCaNt8tmfnqGUthh0BBXY8=; b=ApVGcJXVDnAPR7ZlGUMLIa+QpWzezFsLCrTw7SeMVDpyrpkZqqlR/3K5AdsEVG7blg bjbveMZ8flCeWq1fLNwVY5gDL7Bf0luPBkMIwEyJoQWVRdiA847sSOnL+VnYRMXf5Zpe NRTPFye57GG16bySJryVwHoI9lln5pZHzhbJgDWZ67u0GyZNlXaIoxRcsObkusekszio rpBcadba6VmQI4ri8ugNJ8eJ1XtNhJzk0ex9g4L+issORHH2I8U6IcytlDMbZCwV2b5l MQQoMsXMhVRJQ6QG9jZFzEfnM1hx39y43zqTy74z1Ouv+tS9pHqN+DAxhohJBmsXe9OZ CV6g== X-Gm-Message-State: AOJu0Yzu0HjIa2ZkqTzG9lc0u0BUo7j/YLIsVQAlN8oNVEHhH8dv+WGP 6Pj9GH7yp4W76xTXNhLh8UZ0KnQI4c0myQ== X-Google-Smtp-Source: AGHT+IESfgNd9v/ftTwnb+UNPmZqJiO3FurJZZtw4aXamLO84TMkbMWO1u75P1cby88cc/q5xYhHWw== X-Received: by 2002:a17:903:11d0:b0:1ba:fe63:6616 with SMTP id q16-20020a17090311d000b001bafe636616mr10437450plh.6.1693893967436; Mon, 04 Sep 2023 23:06:07 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id z19-20020a170902ee1300b001b9d8688956sm8458731plb.144.2023.09.04.23.06.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Sep 2023 23:06:06 -0700 (PDT) Message-ID: <23a3e21c-eae5-44d0-8e66-65ada10a9c4d@gmail.com> Date: Tue, 5 Sep 2023 00:06:03 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] VR-VALUES: Rewrite test_for_singularity using range_op_handler Content-Language: en-US To: Andrew Pinski , gcc-patches@gcc.gnu.org References: <20230901173059.791894-1-apinski@marvell.com> <20230901173059.791894-2-apinski@marvell.com> From: Jeff Law In-Reply-To: <20230901173059.791894-2-apinski@marvell.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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 9/1/23 11:30, Andrew Pinski via Gcc-patches wrote: > So it turns out there was a simplier way of starting to > improve VRP to start to fix PR 110131, PR 108360, and PR 108397. > That was rewrite test_for_singularity to use range_op_handler > and Value_Range. > > This patch implements that and > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > gcc/ChangeLog: > > * vr-values.cc (test_for_singularity): Add edge argument > and rewrite using range_op_handler. > (simplify_compare_using_range_pairs): Use Value_Range > instead of value_range and update test_for_singularity call. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/vrp124.c: New test. > * gcc.dg/tree-ssa/vrp125.c: New test. > --- > diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc > index 52ab4fe6109..2474e57ee90 100644 > --- a/gcc/vr-values.cc > +++ b/gcc/vr-values.cc > @@ -904,69 +904,33 @@ simplify_using_ranges::simplify_bit_ops_using_ranges > } > > /* We are comparing trees OP1 and OP2 using COND_CODE. OP1 has > - a known value range VR. > + a known value range OP1_RANGE. > > If there is one and only one value which will satisfy the > - conditional, then return that value. Else return NULL. > - > - If signed overflow must be undefined for the value to satisfy > - the conditional, then set *STRICT_OVERFLOW_P to true. */ > + conditional on the EDGE, then return that value. > + Else return NULL. */ > > static tree > test_for_singularity (enum tree_code cond_code, tree op1, > - tree op2, const value_range *vr) > + tree op2, const int_range_max &op1_range, bool edge) > { > - tree min = NULL; > - tree max = NULL; > - > - /* Extract minimum/maximum values which satisfy the conditional as it was > - written. */ > - if (cond_code == LE_EXPR || cond_code == LT_EXPR) > + /* This is already a singularity. */ > + if (cond_code == NE_EXPR || cond_code == EQ_EXPR) > + return NULL; I don't think this is necessarily the right thing to do for NE. Consider if op1 has the range [0,1] and op2 has the value 1. If the code is NE, then we should be able to return a singularity of 0 since that's the only value for x where x ne 1 is true given the range for x. I like what you're trying to do, it just needs a bit of refinement I think. jeff