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 F3C883857C51 for ; Thu, 22 Dec 2022 21:44:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F3C883857C51 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=1671745458; 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=uQhxSrq5C08G797E0t1tFDRxW92mFZ67PcYTt2Ckiss=; b=Ph6cmZgSS3pXrQSONcTOvckoxIDaGRsHUpqnH+i8uAaSI743X6SSLLQvdj/nR5Vtdq4hSZ JcJNC84OUnUxOLKg4YgaEIo6ywFPe8krJ1m9R8qU0M372/637NxswABVG2vFRR9XQvscnl +xdiAUMtjYOKy/XPQoyMOQVToeR/M+I= 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-347-1aOCC6RTPBSQUJpKQgJQ9g-1; Thu, 22 Dec 2022 16:44:17 -0500 X-MC-Unique: 1aOCC6RTPBSQUJpKQgJQ9g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E480B85A588; Thu, 22 Dec 2022 21:44:16 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.114]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4B4B40C1073; Thu, 22 Dec 2022 21:44:16 +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 2BMLiD3w1200881 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 22 Dec 2022 22:44:13 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2BMLiCDW1200880; Thu, 22 Dec 2022 22:44:12 +0100 Date: Thu, 22 Dec 2022 22:44:12 +0100 From: Jakub Jelinek To: Aldy Hernandez Cc: Richard Biener , gcc-patches , Andrew MacLeod Subject: [PATCH] phiopt, v2: Adjust instead of reset phires range Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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: On Thu, Dec 22, 2022 at 08:46:33PM +0100, Aldy Hernandez wrote: > I haven't looked at your problem above, but have you tried using > int_range_max (or even int_range<2>) instead of value_range above? > > value_range is deprecated and uses the legacy anti-range business, > which has a really hard time representing complex ranges, as well as > union/intersecting them. You're right. With int_range_max it works as I expected. And no, floating point isn't possible here. If value_range is right now just the legacy single range or anti-range, then it explains why it didn't work - while on the first testcase we could have anti-range ~[0, 0], on the second case [-128, -1] U [1, 127] is turned into simple legacy [-128, 127]. So, ok for trunk if this passes bootstrap/regtest? 2022-12-22 Jakub Jelinek Aldy Hernandez * tree-ssa-phiopt.cc (value_replacement): Instead of resetting phires range info, union it with oarg. --- gcc/tree-ssa-phiopt.cc.jj 2022-12-22 12:52:36.588469821 +0100 +++ gcc/tree-ssa-phiopt.cc 2022-12-22 13:11:51.145060050 +0100 @@ -1492,11 +1492,25 @@ value_replacement (basic_block cond_bb, break; } if (equal_p) - /* After the optimization PHI result can have value - which it couldn't have previously. - We could instead of resetting it union the range - info with oarg. */ - reset_flow_sensitive_info (gimple_phi_result (phi)); + { + tree phires = gimple_phi_result (phi); + if (SSA_NAME_RANGE_INFO (phires)) + { + /* After the optimization PHI result can have value + which it couldn't have previously. */ + int_range_max r; + if (get_global_range_query ()->range_of_expr (r, phires, + phi)) + { + int_range<2> tmp (carg, carg); + r.union_ (tmp); + reset_flow_sensitive_info (phires); + set_range_info (phires, r); + } + else + reset_flow_sensitive_info (phires); + } + } if (equal_p && MAY_HAVE_DEBUG_BIND_STMTS) { imm_use_iterator imm_iter; Jakub