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.133.124]) by sourceware.org (Postfix) with ESMTPS id 818D23858427 for ; Fri, 26 Aug 2022 16:40:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 818D23858427 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=1661532028; h=from:from:reply-to: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=ovTKNAF2nWabTLn2o5DNGQ1QV5qhQBc+PmTSs9Mmjtk=; b=VXJvhvnSSqrckBt1JPEQ0ZTgabD520JdePFW9+WbKrUQWOwH4PawW5ru19+0dVa1A2fQjy afmYvOvfMWItvrdnS3d3QHkh2f3uIY7VcATEQ/MRP/5lKxaasRmVNwdKnO1Vk9lD0IoX36 ZG7L0okKWobQbf0MjtdRXvt95Dt8niU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-126-a6CbFjyyPdOKKd_ucwWcQA-1; Fri, 26 Aug 2022 12:40:27 -0400 X-MC-Unique: a6CbFjyyPdOKKd_ucwWcQA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B84E0811E87 for ; Fri, 26 Aug 2022 16:40:26 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 241AD2026D4C; Fri, 26 Aug 2022 16:40:25 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 27QGeM7L225000 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 26 Aug 2022 18:40:23 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 27QGeMnx224999; Fri, 26 Aug 2022 18:40:22 +0200 Date: Fri, 26 Aug 2022 18:40:21 +0200 From: Jakub Jelinek To: Aldy Hernandez Cc: GCC patches , Andrew MacLeod Subject: Re: [PATCH] [ranger] x == -0.0 does not mean we can replace x with -0.0 Message-ID: Reply-To: Jakub Jelinek References: <20220826154606.1155977-1-aldyh@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220826154606.1155977-1-aldyh@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,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 Fri, Aug 26, 2022 at 05:46:06PM +0200, Aldy Hernandez wrote: > On the true side of x == -0.0, we can't just blindly value propagate > the -0.0 into every use of x because x could be +0.0 (or vice versa). > > With this change, we only allow the transformation if > !HONOR_SIGNED_ZEROS or if the range is known not to contain 0. > > Will commit after tests complete. > > gcc/ChangeLog: > > * range-op-float.cc (foperator_equal::op1_range): Do not blindly > copy op2 range when honoring signed zeros. > --- > gcc/range-op-float.cc | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc > index ad2fae578d2..ff9fe312acf 100644 > --- a/gcc/range-op-float.cc > +++ b/gcc/range-op-float.cc > @@ -252,8 +252,21 @@ foperator_equal::op1_range (frange &r, tree type, > switch (get_bool_state (r, lhs, type)) > { > case BRS_TRUE: > - // If it's true, the result is the same as OP2. > - r = op2; > + if (HONOR_SIGNED_ZEROS (type) > + && op2.contains_p (build_zero_cst (type))) What exactly does op2.contains_p for zero? Does it use real_compare/real_equal under the hood, so it is equivalent to op2 == 0.0 or op2 == -0.0, where both will be true whether op2 is -0.0 or 0.0? Or is it more strict and checks whether it is actually a positive zero? In any case, for HONOR_SIGNED_ZEROS, VARYING is unnecessary, all you can do is extend the r range to contain both -0.0 and +0.0 if it contains at least one of them. > + { > + // With signed zeros, x == -0.0 does not mean we can replace > + // x with -0.0, because x may be either +0.0 or -0.0. > + r.set_varying (type); > + } > + else > + { > + // If it's true, the result is the same as OP2. > + // > + // If the range does not actually contain zeros, this should > + // always be OK. > + r = op2; > + } !HONOR_SIGNED_ZEROS doesn't imply that negative zeros won't appear, but says that user doesn't care if he gets a positive or negative zero (unless !MODE_HAS_SIGNED_ZEROS - in that case -0.0 doesn't exist and one doesn't need to bother with it). Now, if all the code setting franges makes sure that for MODE_HAS_SIGNED_ZEROS && !HONOR_SIGNED_ZEROS if +0.0 or -0.0 are inside of a range, then both -0.0 and +0.0 are in the range, then yes, you can use r = op2; > // The TRUE side of op1 == op2 implies op1 is !NAN. > r.set_nan (fp_prop::NO); > break; Jakub