{"id":2232498,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2232498/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/646aa923-385b-45c0-8a2b-870c20db9503@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<646aa923-385b-45c0-8a2b-870c20db9503@redhat.com>","date":"2026-05-04T15:49:17","name":"[COMMITTED,2/6] Integrate bound snapping with pair construction.","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7ad40d4d3ab083ecf5ac99a6e1f407bfb5a3856d","submitter":{"id":7458,"url":"http://patchwork.ozlabs.org/api/1.1/people/7458/?format=json","name":"Andrew MacLeod","email":"amacleod@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/646aa923-385b-45c0-8a2b-870c20db9503@redhat.com/mbox/","series":[{"id":502687,"url":"http://patchwork.ozlabs.org/api/1.1/series/502687/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=502687","date":"2026-05-04T15:49:11","name":"[COMMITTED,1/6] get_tree_range should check the supplied range type.","version":1,"mbox":"http://patchwork.ozlabs.org/series/502687/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2232498/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2232498/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Jck0pqWO;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Jck0pqWO","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g8R126zJtz1yJ9\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 05 May 2026 01:49:58 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id D78A64B9DB6F\n\tfor <incoming@patchwork.ozlabs.org>; Mon,  4 May 2026 15:49:56 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id ADD324BAD15E\n for <gcc-patches@gcc.gnu.org>; Mon,  4 May 2026 15:49:21 +0000 (GMT)","from mail-qt1-f199.google.com (mail-qt1-f199.google.com\n [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-378-EemndmHjMI67P58JWvAZSg-1; Mon, 04 May 2026 11:49:20 -0400","by mail-qt1-f199.google.com with SMTP id\n d75a77b69052e-50da31af14cso109103141cf.1\n for <gcc-patches@gcc.gnu.org>; Mon, 04 May 2026 08:49:20 -0700 (PDT)","from [192.168.49.94] ([68.179.25.249])\n by smtp.gmail.com with ESMTPSA id\n d75a77b69052e-51040911ab7sm100470641cf.9.2026.05.04.08.49.17\n for <gcc-patches@gcc.gnu.org>\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Mon, 04 May 2026 08:49:17 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org D78A64B9DB6F","OpenDKIM Filter v2.11.0 sourceware.org ADD324BAD15E"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org ADD324BAD15E","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org ADD324BAD15E","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777909761; cv=none;\n b=fR2w19Yu8aQ38urUgGMGK4XpqOxarrkzg5BNiAdf9i0Uk/IqVFL/bDQHP3hNl7pzaTnTwJT2mtPVagkZiv7F+QbevMMoJHYw8Khi0E5W57p4GBCJ2UFCqr3XE7HtCU3Q+jc2YmhAa7/VJJhIvet3AZnVehxQB3fjTlrBKtpZelk=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777909761; c=relaxed/simple;\n bh=0mBXhGTy2AgzutNHGH79e3ZTkclij2YF0O822I+oxK0=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject;\n b=r6yMoA0VsKNljbg0R7eG2SVDGnXkeAvmfhDbWjnYl60sOWypgFVTIo7cze4Ojf7PL+jcKEStWoRFhQoCsf01LI31QBeAji9dysRMF4jJ/4C8upJOMoPbR7hu4wqotKzqLsm5YKkQJsbb8uSgeqSwi8/sbsMETav7W6y7hQBIWt8=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1777909761;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type;\n bh=mlH6dB96m2C2x5dVES7SFq3bCD7E+ktD48Va3Q1Fg+I=;\n b=Jck0pqWOaSZp62YoGq759CPB2D1kM3pAvSMhL2taklpYjVVe2n1WSS3kLGe96JB6IlucXu\n XDJ+DtpsqdNNmPhn9dvZwURfbYZzb5ylkCV1pGqIJONqkEhUTjvku/AiGvXn2ryhBt7gtD\n vi7D3vrb9p983kYcWA9aN5gB+2tYNbI=","X-MC-Unique":"EemndmHjMI67P58JWvAZSg-1","X-Mimecast-MFC-AGG-ID":"EemndmHjMI67P58JWvAZSg_1777909759","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777909759; x=1778514559;\n h=subject:from:to:content-language:user-agent:mime-version:date\n :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=K5X9bXDG9MXeku4nu/LQl5gpTLLVGYJQNCu23a5oqJs=;\n b=Ze2DChQNV51a3NFoOf6grcbKli61swzN7SKttPMGHc0qLDiWQpcTA/8+WhRBP2yheQ\n OI/F2SOw2ppdxCjcCjI8JK/fwn3ASnsEoyBGaMzfxXheEBC+pc5KndhhdGx31DVECxDT\n CmsTmqfRg/y4vn5rIZkkLGKOio+qvJ56QNi5D38QDtyDLy4BffhTaVzUmH/woTERNvGk\n JPe0Oofwdn4JXUgrVzb1YGGyQcLH0yQcfFZhn2c12q/0qXN5PS1xXEZSdOVVVNHu+2ZZ\n xJ/QI6PziNIA0HcacsiGnqxi+gfhVIeJ4y+dyUWzKe3UH1ikay8U8Qsxf7W3ygCIWtPq\n 6X0g==","X-Gm-Message-State":"AOJu0YwTfYqW11JH3W/30XMYLe+P7OZxvpYJwU6n4twDuCyKRJh8foOn\n JYZFDCEC7IzS69/Xr08pgQm1I/2OctDtjgkQh4CCJPIN+xZQQsVhnpe2YmfO6GufJpBUyWZJcef\n spcXI72hAsWsw3vKQrZ1Hk7IcAgAacUmxyAkE+BBI9fJmTykdWC3hJS76i0qOug8upW4OQZLfPj\n 1XGncIRmT7VHoRr5jDSMbMMqVwOazn85o4cV+4cV+mJvY=","X-Gm-Gg":"AeBDieul5yN1Q/ftMPkH5I7BjzKI4Ynv1hbKCR6sDwNtqgPY/WlHiV4mH/5ZnoEgbUc\n xRjQ9jYgndlUAo12ALlJBKuJiNq8GRfaOl23ALEVQbN4wriZoTjJEzt+01Cem4SZUjeb7gVLozB\n +Fcj7eQzla91myf0utPEtex+LDrhVy/05PhyfD3wbtssjIzxJ94rpTN5X+RTGPQ4xBM8Ah9l0BX\n kojYLor0IlWa3XHoNy1aBRGLXXHNqxF3qedhw3vOFubAfl/0l/ZDED1ClsT7XuHQn7bGvJcz8s+\n icPKyz7MIUdLJ0HjSzhiQhcz3Vqy0ZgzUZCrf7ysZR9uYY/w/YD2yP21p1M05Qu7jWa1Cxt3P7d\n VTXmDaQ0DIW1rKudmJ8AzgU5zpLmlEoxcE34=","X-Received":["by 2002:a05:622a:5a91:b0:50d:3eac:8466 with SMTP id\n d75a77b69052e-5104bf0a3c8mr149536321cf.30.1777909759148;\n Mon, 04 May 2026 08:49:19 -0700 (PDT)","by 2002:a05:622a:5a91:b0:50d:3eac:8466 with SMTP id\n d75a77b69052e-5104bf0a3c8mr149535861cf.30.1777909758611;\n Mon, 04 May 2026 08:49:18 -0700 (PDT)"],"Message-ID":"<646aa923-385b-45c0-8a2b-870c20db9503@redhat.com>","Date":"Mon, 4 May 2026 11:49:17 -0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","To":"gcc-patches <gcc-patches@gcc.gnu.org>","From":"Andrew MacLeod <amacleod@redhat.com>","Subject":"[COMMITTED 2/6] Integrate bound snapping with pair construction.","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"kXohR5FnzwuLOTZjJPlDYxpBg7TDZyVvJxwHQAG72HQ_1777909759","X-Mimecast-Originator":"redhat.com","Content-Type":"multipart/mixed; boundary=\"------------EA3TyFywJToHFlW1AYjG3t0n\"","Content-Language":"en-US","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"When performing an intersect, we build a list of subranges, and then \nperform bounds snapping to ensure endpoints all match any bitmask.   Tis \ncan also eliminate entire subranges.  It is more efficient to simply \nsnap the bounds as the sub ranges are built, and eliminate invalid \nsubranges before they are even added.\n\nThis patch implements bound snapping within intersect while building the \nranges.\n\nBootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed.\n\nAndrew","diff":"From e1e1d8f2da43af0b77a712ab8c0ffd8752aed18c Mon Sep 17 00:00:00 2001\nFrom: Andrew MacLeod <amacleod@redhat.com>\nDate: Mon, 5 Jan 2026 16:51:12 -0500\nSubject: [PATCH 2/6] Integrate bound snapping with pair construction.\n\nRather than build all the pairs and then apply a mask to those pairs,\napply the mask to each pair as they are constructed.\n\n\t* value-range.cc (irange::intersect): Snap bounds as they are created.\n---\n gcc/value-range.cc | 48 ++++++++++++++++++++++++++++++----------------\n 1 file changed, 32 insertions(+), 16 deletions(-)\n\ndiff --git a/gcc/value-range.cc b/gcc/value-range.cc\nindex eeb3abffe6c..657afa0acaa 100644\n--- a/gcc/value-range.cc\n+++ b/gcc/value-range.cc\n@@ -2095,6 +2095,7 @@ irange::intersect (const vrange &v)\n   int_range_max r2 (*this);\n   unsigned r2_lim = r2.num_pairs ();\n   unsigned i2 = 0;\n+  bool need_snapping = !m_bitmask.unknown_p ();\n   for (unsigned i = 0; i < r.num_pairs (); )\n     {\n       // If r1's upper is < r2's lower, we can skip r1's pair.\n@@ -2128,29 +2129,51 @@ irange::intersect (const vrange &v)\n \t    m_base[bld_pair * 2] = r2l;\n \t}\n       else\n-\t// Decrease and set a new upper.\n+\t// Decrease the index to use the existing lower bound, and\n+\t// set a new upper for this pair.\n \tbld_pair--;\n \n+      // Changes to false if the last value in i2's range is consumed.\n+      bool more = true;\n       // ...and choose the lower of the upper bounds.\n       if (wi::le_p (ru, r2u, sign))\n \t{\n \t  m_base[bld_pair * 2 + 1] = ru;\n-\t  bld_pair++;\n \t  // Move past the r1 pair and keep trying.\n \t  i++;\n-\t  continue;\n \t}\n       else\n \t{\n \t  m_base[bld_pair * 2 + 1] = r2u;\n-\t  bld_pair++;\n \t  i2++;\n-\t  if (i2 < r2_lim)\n-\t    continue;\n-\t  // No more r2, break.\n-\t  break;\n+\t  // No more r2, break the loop when done.\n+\t  if (i2 >= r2_lim)\n+\t    more = false;\n \t}\n-      // r2 has the higher lower bound.\n+      // Now snap these ranges to the bitmask, if there is one.\n+      if (need_snapping)\n+\t{\n+\t  bool ovf;\n+\t  wide_int lb, ub;\n+\t  if (snap (m_base[bld_pair * 2], m_base[bld_pair * 2 + 1],\n+\t\t    lb, ub, ovf))\n+\t    {\n+\t      // If the new subrange does not fit the mask, skip it.\n+\t      if (ovf)\n+\t\t{\n+\t\t  if (!more)\n+\t\t    break;\n+\t\t  continue;\n+\t\t}\n+\t      // Otherwise adjust the pair.\n+\t      m_base[bld_pair * 2] = lb;\n+\t      m_base[bld_pair * 2 + 1] = ub;\n+\t    }\n+\t}\n+      // Current pair now satisfies any mask, ready for another pair.\n+      bld_pair++;\n+      if (!more)\n+\tbreak;\n     }\n \n   // At the exit of this loop, it is one of 2 things:\n@@ -2163,13 +2186,6 @@ irange::intersect (const vrange &v)\n     }\n \n   m_kind = VR_RANGE;\n-  // Snap subranges if there is a bitmask.  See PR 123319.\n-  if (!m_bitmask.unknown_p ())\n-    {\n-      snap_subranges ();\n-      if (undefined_p ())\n-\treturn true;\n-    }\n   // The range has been altered, so normalize it even if nothing\n   // changed in the mask.\n   if (!intersect_bitmask (r))\n-- \n2.45.0\n\n","prefixes":["COMMITTED","2/6"]}