tree-optimization/121323 - UBSAN error in ao_ref_init_from_ptr_and_range

We should check the offset fits a HWI when multiplied to be in bits.

	PR tree-optimization/121323
	* tree-ssa-alias.cc (ao_ref_init_from_ptr_and_range): Check
	the pointer offset fits in a HWI when represented in bits.

(cherry picked from commit 0be8ffbc854410b65d45a72e843dc18b13fc7b0f)
diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index 9dd1780..f60ed09 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -901,7 +901,9 @@
   if (TREE_CODE (ptr) == ADDR_EXPR)
     {
       ref->base = get_addr_base_and_unit_offset (TREE_OPERAND (ptr, 0), &t);
-      if (ref->base)
+      if (ref->base
+	  && coeffs_in_range_p (t, -HOST_WIDE_INT_MAX / BITS_PER_UNIT,
+				HOST_WIDE_INT_MAX / BITS_PER_UNIT))
 	ref->offset = BITS_PER_UNIT * t;
       else
 	{