[COMMITTED] PR tree-optimization/127154 - Dont access unused fields in set_prange.

Message ID 5211af84-32a4-4ed8-8ab4-c9a441424f02@redhat.com
State New
Headers
Series [COMMITTED] PR tree-optimization/127154 - Dont access unused fields in set_prange. |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap fail Patch failed to apply
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap fail Patch failed to apply

Commit Message

Andrew MacLeod Sept. 1, 2026, 12:55 p.m. UTC
  There is no simple way to test this, but valgrind was unhappy about the 
sequence of instructions in prange_storage::set_prange ().   UNDEFINED, 
VARYING and ZERO modes don't really use the m_bitmask nor m_points_to 
field.  Although the query for the current bitmask should be harmless, 
this patch moves it down to the section where we know we are using it, 
and sets the defaults to FALSE for the other 3 cases.

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

Andrew
  

Patch

From da6ac91f21c3472c6067c8e7d65179de7770d16c Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Mon, 31 Aug 2026 10:00:27 -0400
Subject: [PATCH 1/2] Dont access unused fields in set_prange.

	PR tree-optimization/127154
	* value-range-storage.cc (prange_storage::set_prange) Access
	bitmask and points to fields only for kinds those that use them
---
 gcc/value-range-storage.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc
index 827a5260a19..14fa6e29a9f 100644
--- a/gcc/value-range-storage.cc
+++ b/gcc/value-range-storage.cc
@@ -710,9 +710,9 @@  prange_storage::set_prange (const prange &r)
 {
   unsigned num_words;
   m_kind = prange_format (r, num_words);
-  m_has_bitmask = !r.get_bitmask ().unknown_p ();
+  m_has_bitmask = false;
+  m_points_to_p = false;
   m_pt = r.m_pt;
-  m_points_to_p = r.m_points_to_p;
 
   unsigned index = 0;
 
@@ -733,6 +733,9 @@  prange_storage::set_prange (const prange &r)
 	gcc_unreachable ();
     }
 
+  m_has_bitmask = !r.get_bitmask ().unknown_p ();
+  m_points_to_p = r.m_points_to_p;
+
   if (m_has_bitmask)
     {
       irange_bitmask bm = r.m_bitmask;
-- 
2.55.0