https://gcc.gnu.org/g:4f593db8803cc8df796314ca9e15a72c51d6bde9
commit r15-5779-g4f593db8803cc8df796314ca9e15a72c51d6bde9 Author: Tejas Belagod <tejas.bela...@arm.com> Date: Thu Sep 5 14:38:38 2024 +0530 gimple: Handle variable-sized vectors in BIT_FIELD_REF Handle variable-sized vectors for BIT_FIELD_REF canonicalization. gcc/ChangeLog: * gimple-fold.cc (maybe_canonicalize_mem_ref_addr): Handle variable sized vector types in BIT_FIELD_REF canonicalization. * tree-cfg.cc (verify_types_in_gimple_reference): Change object-size- checking for BIT_FIELD_REF to error offsets that are known_gt to be outside object-size. Out-of-range offsets can happen in the case of indices that reference VLA SVE vector elements that may be outside the minimum vector size range and therefore maybe_gt is not appropirate here. Diff: --- gcc/gimple-fold.cc | 2 +- gcc/tree-cfg.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index ba2c94794de0..3c72cd6c79ae 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -6347,7 +6347,7 @@ maybe_canonicalize_mem_ref_addr (tree *t, bool is_debug = false) (TYPE_SIZE (TREE_TYPE (*t)))); widest_int ext = wi::add (idx, wi::to_widest (TYPE_SIZE (TREE_TYPE (*t)))); - if (wi::les_p (ext, wi::to_widest (TYPE_SIZE (vtype)))) + if (maybe_le (ext, wi::to_poly_widest (TYPE_SIZE (vtype)))) { *t = build3_loc (EXPR_LOCATION (*t), BIT_FIELD_REF, TREE_TYPE (*t), diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 9ac8304e6769..87f9776c4171 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -3175,7 +3175,7 @@ verify_types_in_gimple_reference (tree expr, bool require_lvalue) return true; } if (!AGGREGATE_TYPE_P (TREE_TYPE (op)) - && maybe_gt (size + bitpos, + && known_gt (size + bitpos, tree_to_poly_uint64 (TYPE_SIZE (TREE_TYPE (op))))) { error ("position plus size exceeds size of referenced object in "