[v3,4/8] gimple: Handle variable-sized vectors in BIT_FIELD_REF

Message ID 20241129035404.3363162-5-tejas.belagod@arm.com
State Committed
Commit 4f593db8803cc8df796314ca9e15a72c51d6bde9
Headers
Series aarch64: Enable C/C++ operations on SVE ACLE types. |

Commit Message

Tejas Belagod Nov. 29, 2024, 3:54 a.m. UTC
  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.
---
 gcc/gimple-fold.cc | 2 +-
 gcc/tree-cfg.cc    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5eedad54ced..4ad5ae03d91 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -6293,7 +6293,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 9ac8304e676..87f9776c417 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 "