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 3931B3858C2D for ; Tue, 11 Oct 2022 13:57:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3931B3858C2D 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=1665496676; 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: in-reply-to:in-reply-to:references:references; bh=XYmMtOSwwAtVZCNqwTSJ9zv22oNigU0MWwr3gwNrG+s=; b=gx27VB3HlL56udMBDDyAYT40X1TT748yuVb6C9/mbsY3UHNn91uXYwgz/38AwgW0VgliYC rddgNtNO3+7wM4Vl3JvDDTbDPtHReOvpkuw9Yjg1PptvwQWeqoBqT0pkrYFb7iImBLgNAb +GBspcfB1LVjcA4QvrNvCCzlBIIJxIE= Received: from mail-yw1-f197.google.com (mail-yw1-f197.google.com [209.85.128.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-163-LenOOcYKOleCWV2etOnGNA-1; Tue, 11 Oct 2022 09:57:56 -0400 X-MC-Unique: LenOOcYKOleCWV2etOnGNA-1 Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-349423f04dbso134169297b3.13 for ; Tue, 11 Oct 2022 06:57:56 -0700 (PDT) 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:message-id :reply-to; bh=XYmMtOSwwAtVZCNqwTSJ9zv22oNigU0MWwr3gwNrG+s=; b=p33D5qfTCIzCNNWqFWDI5CFuM0Biry4KG0ijAZWlvEQ3cWfl8GEaTI0QM+vrNnNnlI C26M9e1m+zxh7D/c4/3lgIjW/4cBnftaTwS0hD5TzR5GJGbNg3tywCUDF38/jFsVAeRu KQLMuZlMeNcQ0WMtYRf2z0kbPANuTyNVInxYOYBOgkib0cTIO0n9OU7GgxtZmiBCaZ++ ieAMNGY6Xtc/R9ZMpiS7Qi9E/y7gJNXIJVdFV0A7inOn83afutBI1OMdEOgxMVt4KGuk UiMaSm98vMiTcq6ffQAJ1hAnX2mUi0ze5ziJNa5F0KnUOegC1nrFHWOzx0McJmtxZL7a VI4w== X-Gm-Message-State: ACrzQf2TvbGwkTyi/TONurs2P464AYzf9ZIHrmo4Wh71ESN1Du5fuIpu er5CZ3C2uMSCbqdH4IT2FK0FxXDCnZxZV6oyB0C64P07QezKJ2nNODyLFQ9ilokIoaREhdbSvAP kex3vBOTwAKijtqJibqk5g4LEvjPdCcqllg== X-Received: by 2002:a25:23c5:0:b0:6bd:ebf2:ff9d with SMTP id j188-20020a2523c5000000b006bdebf2ff9dmr23791409ybj.80.1665496675177; Tue, 11 Oct 2022 06:57:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6IYjf3WvMqVKYHj+J6VyLTHkWuFrAAC8uqqBPgpFWfShJACnYKBvNN1bWIfKhS3KCwkegyy7v6LnmhImnOm38= X-Received: by 2002:a25:23c5:0:b0:6bd:ebf2:ff9d with SMTP id j188-20020a2523c5000000b006bdebf2ff9dmr23791394ybj.80.1665496674891; Tue, 11 Oct 2022 06:57:54 -0700 (PDT) MIME-Version: 1.0 References: <20221011135136.369644-1-aldyh@redhat.com> <20221011135136.369644-3-aldyh@redhat.com> In-Reply-To: <20221011135136.369644-3-aldyh@redhat.com> From: Aldy Hernandez Date: Tue, 11 Oct 2022 15:57:43 +0200 Message-ID: Subject: Re: [COMMITTED] Implement op1_range operators for unordered comparisons. To: GCC patches Cc: Andrew MacLeod X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,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: I forgot to mention. These were lifted from the integer counterparts. Most of the code is the same, as the build_{cond} code in the frange version will add the appropriate NAN (unless -ffinite-math-only), and all we have to do is clear it on the false edge. Aldy On Tue, Oct 11, 2022 at 3:51 PM Aldy Hernandez wrote: > > gcc/ChangeLog: > > * range-op-float.cc (foperator_unordered_le::op1_range): New. > (foperator_unordered_le::op2_range): New. > (foperator_unordered_gt::op1_range): New. > (foperator_unordered_gt::op2_range): New. > (foperator_unordered_ge::op1_range): New. > (foperator_unordered_ge::op2_range): New. > (foperator_unordered_equal::op1_range): New. > --- > gcc/range-op-float.cc | 205 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 205 insertions(+) > > diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc > index 8dd4bcc70c0..ef51b7538e3 100644 > --- a/gcc/range-op-float.cc > +++ b/gcc/range-op-float.cc > @@ -1162,6 +1162,8 @@ public: > class foperator_unordered_le : public range_operator_float > { > using range_operator_float::fold_range; > + using range_operator_float::op1_range; > + using range_operator_float::op2_range; > public: > bool fold_range (irange &r, tree type, > const frange &op1, const frange &op2, > @@ -1184,11 +1186,65 @@ public: > return true; > } > } > + bool op1_range (frange &r, tree type, > + const irange &lhs, const frange &op2, > + relation_kind rel) const final override; > + bool op2_range (frange &r, tree type, > + const irange &lhs, const frange &op1, > + relation_kind rel) const final override; > } fop_unordered_le; > > +bool > +foperator_unordered_le::op1_range (frange &r, tree type, > + const irange &lhs, const frange &op2, > + relation_kind) const > +{ > + switch (get_bool_state (r, lhs, type)) > + { > + case BRS_TRUE: > + build_le (r, type, op2); > + break; > + > + case BRS_FALSE: > + build_gt (r, type, op2); > + r.clear_nan (); > + break; > + > + default: > + break; > + } > + return true; > +} > + > +bool > +foperator_unordered_le::op2_range (frange &r, > + tree type, > + const irange &lhs, > + const frange &op1, > + relation_kind) const > +{ > + switch (get_bool_state (r, lhs, type)) > + { > + case BRS_TRUE: > + build_ge (r, type, op1); > + break; > + > + case BRS_FALSE: > + build_lt (r, type, op1); > + r.clear_nan (); > + break; > + > + default: > + break; > + } > + return true; > +} > + > class foperator_unordered_gt : public range_operator_float > { > using range_operator_float::fold_range; > + using range_operator_float::op1_range; > + using range_operator_float::op2_range; > public: > bool fold_range (irange &r, tree type, > const frange &op1, const frange &op2, > @@ -1211,11 +1267,67 @@ public: > return true; > } > } > + bool op1_range (frange &r, tree type, > + const irange &lhs, const frange &op2, > + relation_kind rel) const final override; > + bool op2_range (frange &r, tree type, > + const irange &lhs, const frange &op1, > + relation_kind rel) const final override; > } fop_unordered_gt; > > +bool > +foperator_unordered_gt::op1_range (frange &r, > + tree type, > + const irange &lhs, > + const frange &op2, > + relation_kind) const > +{ > + switch (get_bool_state (r, lhs, type)) > + { > + case BRS_TRUE: > + build_gt (r, type, op2); > + break; > + > + case BRS_FALSE: > + build_le (r, type, op2); > + r.clear_nan (); > + break; > + > + default: > + break; > + } > + return true; > +} > + > +bool > +foperator_unordered_gt::op2_range (frange &r, > + tree type, > + const irange &lhs, > + const frange &op1, > + relation_kind) const > +{ > + switch (get_bool_state (r, lhs, type)) > + { > + case BRS_TRUE: > + build_lt (r, type, op1); > + break; > + > + case BRS_FALSE: > + build_ge (r, type, op1); > + r.clear_nan (); > + break; > + > + default: > + break; > + } > + return true; > +} > + > class foperator_unordered_ge : public range_operator_float > { > using range_operator_float::fold_range; > + using range_operator_float::op1_range; > + using range_operator_float::op2_range; > public: > bool fold_range (irange &r, tree type, > const frange &op1, const frange &op2, > @@ -1238,11 +1350,66 @@ public: > return true; > } > } > + bool op1_range (frange &r, tree type, > + const irange &lhs, const frange &op2, > + relation_kind rel) const final override; > + bool op2_range (frange &r, tree type, > + const irange &lhs, const frange &op1, > + relation_kind rel) const final override; > } fop_unordered_ge; > > +bool > +foperator_unordered_ge::op1_range (frange &r, > + tree type, > + const irange &lhs, > + const frange &op2, > + relation_kind) const > +{ > + switch (get_bool_state (r, lhs, type)) > + { > + case BRS_TRUE: > + build_ge (r, type, op2); > + break; > + > + case BRS_FALSE: > + build_lt (r, type, op2); > + r.clear_nan (); > + break; > + > + default: > + break; > + } > + return true; > +} > + > +bool > +foperator_unordered_ge::op2_range (frange &r, tree type, > + const irange &lhs, > + const frange &op1, > + relation_kind) const > +{ > + switch (get_bool_state (r, lhs, type)) > + { > + case BRS_TRUE: > + build_le (r, type, op1); > + break; > + > + case BRS_FALSE: > + build_gt (r, type, op1); > + r.clear_nan (); > + break; > + > + default: > + break; > + } > + return true; > +} > + > class foperator_unordered_equal : public range_operator_float > { > using range_operator_float::fold_range; > + using range_operator_float::op1_range; > + using range_operator_float::op2_range; > public: > bool fold_range (irange &r, tree type, > const frange &op1, const frange &op2, > @@ -1265,8 +1432,46 @@ public: > return true; > } > } > + bool op1_range (frange &r, tree type, > + const irange &lhs, const frange &op2, > + relation_kind rel) const final override; > + bool op2_range (frange &r, tree type, > + const irange &lhs, const frange &op1, > + relation_kind rel) const final override > + { > + return op1_range (r, type, lhs, op1, rel); > + } > } fop_unordered_equal; > > +bool > +foperator_unordered_equal::op1_range (frange &r, tree type, > + const irange &lhs, > + const frange &op2, > + relation_kind) const > +{ > + switch (get_bool_state (r, lhs, type)) > + { > + case BRS_TRUE: > + // If it's true, the result is the same as OP2 plus a NAN. > + r = op2; > + // Add both zeros if there's the possibility of zero equality. > + frange_add_zeros (r, type); > + // Add the posibility of a NAN. > + r.update_nan (); > + break; > + > + case BRS_FALSE: > + // The false side indictates !NAN and not equal. We can at least > + // represent !NAN. > + r.set_varying (type); > + r.clear_nan (); > + break; > + > + default: > + break; > + } > + return true; > +} > > // Instantiate a range_op_table for floating point operations. > static floating_op_table global_floating_table; > -- > 2.37.3 >