From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 92A2F385770C for ; Tue, 11 Apr 2023 08:59:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 92A2F385770C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681203592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KM9RsEneEglbNZ0YHKYPtttnyIFOzE9t1qlUKGeORuc=; b=K0KVWbKSP26bwYTJnp7rygcHWqnJXmLxpeI1fnYce1+jTI3RzSAhFRj8jTi8BydZEJTfTr l5OoSJbDePe2sRAJczKFF/9G/BKIqegJJ7ZZEmFwZf1f92ESXGh9vA0FnW+mN75kIrnGyh nzw3KHdEVsvqA7YanuGyn+Fy4y9uaBE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-eN1qRzTePuawYl6r5uh6_w-1; Tue, 11 Apr 2023 04:59:51 -0400 X-MC-Unique: eN1qRzTePuawYl6r5uh6_w-1 Received: by mail-wr1-f69.google.com with SMTP id w3-20020adf8bc3000000b002efb4354084so604341wra.10 for ; Tue, 11 Apr 2023 01:59:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681203590; x=1683795590; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KM9RsEneEglbNZ0YHKYPtttnyIFOzE9t1qlUKGeORuc=; b=4R8ykuQ0LcGNDhlkADB8WDRb0tolRXa1SqD6GEBn1bVDUYChpC18Od6f0X/xW690oD IyIkUmEce+uFMLeRcDdcM//ABWD79UKqZg4NyMfTPRRcihKaoW+FzSDlU59Sj8qFwkbp wBpUBat5Jr4gWFVDSqzo76pVqYOfG72NOHEWra65PQFUr3HsQLhM5M00tFGA58f/jzw1 SogpqSCXWU6Y/3vXC1gBp6uHN2cJJFn27rPRnh2eip7S8/9fqV9RW0XbLyVug0Au3Yjq Z0pnnDmPGAdxOL8UCaNzs9vLkUEg7MVnza7pB65Ma0XPbumsZJtK67YUtPRMAAqPAjn7 Wf1w== X-Gm-Message-State: AAQBX9e3PChuwJkV9UpXzZ8E8EuMfdZ4468mj965E1Cwm4PjZrJ73zyl Zy55O9+I82q5qMS3TjuJKRBaG/L4ie74OFzM6x70yqlEa8xtNs5BYzweAELHIUbxcGaIzq0e08m wS6NFF7w2DcN9wfwziA== X-Received: by 2002:a1c:f20c:0:b0:3ee:526f:b15e with SMTP id s12-20020a1cf20c000000b003ee526fb15emr8541591wmc.23.1681203590610; Tue, 11 Apr 2023 01:59:50 -0700 (PDT) X-Google-Smtp-Source: AKy350ZE6S4GPb2ehQ+J4MFDKVdTq/C6smFmNs84vosenkGgo1yz16xMisrBpqplGKRKvPOA6DO10g== X-Received: by 2002:a1c:f20c:0:b0:3ee:526f:b15e with SMTP id s12-20020a1cf20c000000b003ee526fb15emr8541578wmc.23.1681203590235; Tue, 11 Apr 2023 01:59:50 -0700 (PDT) Received: from [192.168.1.201] ([139.47.42.170]) by smtp.gmail.com with ESMTPSA id f4-20020a7bcd04000000b003ed1f6878a5sm16431594wmj.5.2023.04.11.01.59.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 01:59:49 -0700 (PDT) Message-ID: Date: Tue, 11 Apr 2023 10:59:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [RFC PATCH] range-op-float: Fix up op1_op2_relation of comparisons To: Jakub Jelinek , Andrew MacLeod Cc: gcc-patches@gcc.gnu.org References: From: Aldy Hernandez In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no 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 4/11/23 10:21, Jakub Jelinek wrote: > Hi! > > This patch was what I've tried first before the currently committed > PR109386 fix. Still, I think it is the right thing until we have proper > full set of VREL_* relations for NANs (though it would be really nice > if op1_op2_relation could be passed either type of the comparison > operands, or even better ranges of the two operands, such that > we could choose if inversion of say VREL_LT is VREL_GE (if !MODE_HONOR_NANS > (TYPE_MODE (type))) or rhs1/rhs2 ranges are guaranteed not to include > NANs (!known_isnan && !maybe_isnan for both), or VREL_UNGE, etc. > Anyway, the current state is that for the LE/LT/GE/GT comparisons > we pretend the inverse is like for integral comparisons, which is > true only if NANs can't appear in operands, while for UNLE/UNLT/UNGE/UNGT > we don't override op1_op2_relation (so it always yields VREL_VARYING). > > Though, this patch regresses the > FAIL: gcc.dg/tree-ssa/vrp-float-6.c scan-tree-dump-times evrp "Folding predicate x_.* <= y_.* to 1" 1 > test, so am not sure what to do with it. The test has explicit > !isnan tests around it, so e.g. having the ranges passed to op1_op2_relation > would also fix it. I'll defer to Andrew on this, as he's the master of the relation oracle :). Aldy > > 2023-04-11 Jakub Jelinek > > * range-op-float.cc (foperator_lt::op1_op2_relation): Return > VREL_VARYING instead of VREL_GE. > (foperator_le::op1_op2_relation): Return VREL_VARYING instead of > VREL_GT. > (foperator_gt::op1_op2_relation): Return VREL_VARYING instead of > VREL_LE. > (foperator_ge::op1_op2_relation): Return VREL_VARYING instead of > VREL_LT. > (foperator_unordered_lt::op1_op2_relation, > foperator_unordered_le::op1_op2_relation, > foperator_unordered_gt::op1_op2_relation, > foperator_unordered_ge::op1_op2_relation): New. > > --- gcc/range-op-float.cc.jj 2023-04-01 09:32:02.635423345 +0200 > +++ gcc/range-op-float.cc 2023-04-03 10:42:54.000000000 +0200 > @@ -831,7 +831,10 @@ public: > relation_trio = TRIO_VARYING) const final override; > relation_kind op1_op2_relation (const irange &lhs) const final override > { > - return lt_op1_op2_relation (lhs); > + relation_kind ret = lt_op1_op2_relation (lhs); > + if (ret == VREL_GE) > + ret = VREL_VARYING; // Inverse of VREL_LT is VREL_UNGE. > + return ret; > } > bool op1_range (frange &r, tree type, > const irange &lhs, const frange &op2, > @@ -947,6 +950,10 @@ public: > relation_trio rel = TRIO_VARYING) const final override; > relation_kind op1_op2_relation (const irange &lhs) const final override > { > + relation_kind ret = le_op1_op2_relation (lhs); > + if (ret == VREL_GT) > + ret = VREL_VARYING; // Inverse of VREL_LE is VREL_UNGT. > + return ret; > return le_op1_op2_relation (lhs); > } > bool op1_range (frange &r, tree type, > @@ -1057,7 +1064,10 @@ public: > relation_trio = TRIO_VARYING) const final override; > relation_kind op1_op2_relation (const irange &lhs) const final override > { > - return gt_op1_op2_relation (lhs); > + relation_kind ret = gt_op1_op2_relation (lhs); > + if (ret == VREL_LE) > + ret = VREL_VARYING; // Inverse of VREL_GT is VREL_UNLE. > + return ret; > } > bool op1_range (frange &r, tree type, > const irange &lhs, const frange &op2, > @@ -1177,7 +1187,10 @@ public: > relation_trio = TRIO_VARYING) const final override; > relation_kind op1_op2_relation (const irange &lhs) const final override > { > - return ge_op1_op2_relation (lhs); > + relation_kind ret = ge_op1_op2_relation (lhs); > + if (ret == VREL_LT) > + ret = VREL_VARYING; // Inverse of VREL_GE is VREL_UNLT. > + return ret; > } > bool op1_range (frange &r, tree type, > const irange &lhs, const frange &op2, > @@ -1571,6 +1584,7 @@ class foperator_unordered_lt : public ra > using range_operator_float::fold_range; > using range_operator_float::op1_range; > using range_operator_float::op2_range; > + using range_operator_float::op1_op2_relation; > public: > bool fold_range (irange &r, tree type, > const frange &op1, const frange &op2, > @@ -1599,6 +1613,13 @@ public: > return true; > } > } > + relation_kind op1_op2_relation (const irange &lhs) const final override > + { > + relation_kind ret = lt_op1_op2_relation (lhs); > + if (ret == VREL_LT) > + ret = VREL_VARYING; // Should have been VREL_UNLT. > + return ret; > + } > bool op1_range (frange &r, tree type, > const irange &lhs, > const frange &op2, > @@ -1682,6 +1703,7 @@ class foperator_unordered_le : public ra > using range_operator_float::fold_range; > using range_operator_float::op1_range; > using range_operator_float::op2_range; > + using range_operator_float::op1_op2_relation; > public: > bool fold_range (irange &r, tree type, > const frange &op1, const frange &op2, > @@ -1710,6 +1732,13 @@ public: > return true; > } > } > + relation_kind op1_op2_relation (const irange &lhs) const final override > + { > + relation_kind ret = le_op1_op2_relation (lhs); > + if (ret == VREL_LE) > + ret = VREL_VARYING; // Should have been VREL_UNLE. > + return ret; > + } > bool op1_range (frange &r, tree type, > const irange &lhs, const frange &op2, > relation_trio = TRIO_VARYING) const final override; > @@ -1789,6 +1818,7 @@ class foperator_unordered_gt : public ra > using range_operator_float::fold_range; > using range_operator_float::op1_range; > using range_operator_float::op2_range; > + using range_operator_float::op1_op2_relation; > public: > bool fold_range (irange &r, tree type, > const frange &op1, const frange &op2, > @@ -1817,6 +1847,13 @@ public: > return true; > } > } > + relation_kind op1_op2_relation (const irange &lhs) const final override > + { > + relation_kind ret = gt_op1_op2_relation (lhs); > + if (ret == VREL_GT) > + ret = VREL_VARYING; // Should have been VREL_UNGT. > + return ret; > + } > bool op1_range (frange &r, tree type, > const irange &lhs, const frange &op2, > relation_trio = TRIO_VARYING) const final override; > @@ -1900,6 +1937,7 @@ class foperator_unordered_ge : public ra > using range_operator_float::fold_range; > using range_operator_float::op1_range; > using range_operator_float::op2_range; > + using range_operator_float::op1_op2_relation; > public: > bool fold_range (irange &r, tree type, > const frange &op1, const frange &op2, > @@ -1928,6 +1966,13 @@ public: > return true; > } > } > + relation_kind op1_op2_relation (const irange &lhs) const final override > + { > + relation_kind ret = ge_op1_op2_relation (lhs); > + if (ret == VREL_GE) > + ret = VREL_VARYING; // Should have been VREL_UNGE. > + return ret; > + } > bool op1_range (frange &r, tree type, > const irange &lhs, const frange &op2, > relation_trio = TRIO_VARYING) const final override; > > Jakub >