https://gcc.gnu.org/g:3ef3de7a7329d5c76bed31e8b49a2a661c45f72f

commit r15-10185-g3ef3de7a7329d5c76bed31e8b49a2a661c45f72f
Author: Richard Biener <rguent...@suse.de>
Date:   Thu Jul 31 13:06:36 2025 +0200

    tree-optimization/121320 - UBSAN error in ao_ref_init_from_vn_reference
    
    The multiplication by BITS_PER_UNIT should be done in poly_offset_int.
    
            PR tree-optimization/121320
            * tree-ssa-sccvn.cc (ao_ref_init_from_vn_reference): Convert
            op->off to poly_offset_int before multiplying by
            BITS_PER_UNIT.
    
    (cherry picked from commit ff6f7d8e005ae94ffd55f1dba727e28531c3daf3)

Diff:
---
 gcc/tree-ssa-sccvn.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 7f2500e5d591..9bf25c67dc95 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -1219,7 +1219,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref,
                  offset = 0;
                }
              else
-               offset += pop->off * BITS_PER_UNIT;
+               offset += poly_offset_int (pop->off) * BITS_PER_UNIT;
              op0_p = NULL;
              break;
            }
@@ -1270,7 +1270,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref,
          if (maybe_eq (op->off, -1))
            max_size = -1;
          else
-           offset += op->off * BITS_PER_UNIT;
+           offset += poly_offset_int (op->off) * BITS_PER_UNIT;
          break;
 
        case REALPART_EXPR:

Reply via email to