bitmask_intersection should not return immediately if the current mask is unknown.

Unknown often means it is the default for a range, and this may interact in interesting ways with the other bitmask, producing more precise results.

Bootstraps on  x86_64-pc-linux-gnu with no regressions.   Pushed.

Andrew
From b3327649bffd32af962662dce054b94be2d7330d Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacl...@redhat.com>
Date: Wed, 14 May 2025 11:13:15 -0400
Subject: [PATCH 3/4] Allow bitmask intersection to process unknown masks.

bitmask_intersection should not return immediately if the current mask is
unknown.  Unknown may mean its the default for a range, and this may
interact in intersting ways with the other bitmask.

	PR tree-optimization/116546
	* value-range.cc (irange::intersect_bitmask): Allow unknown
	bitmasks to be processed.
---
 gcc/value-range.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 64d10f41168..ed3760fa6ff 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -2434,7 +2434,7 @@ irange::intersect_bitmask (const irange &r)
 {
   gcc_checking_assert (!undefined_p () && !r.undefined_p ());
 
-  if (r.m_bitmask.unknown_p () || m_bitmask == r.m_bitmask)
+  if (m_bitmask == r.m_bitmask)
     return false;
 
   irange_bitmask bm = get_bitmask ();
-- 
2.45.0

Reply via email to