public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Fix creation of TARGET_MEM_REFs with __capability alias pointers
@ 2022-05-06 14:45 Matthew Malcomson
  0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-05-06 14:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4a3316ead461a73e15833c2315b4a370b0cd0bbb

commit 4a3316ead461a73e15833c2315b4a370b0cd0bbb
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Wed Apr 27 18:50:32 2022 +0100

    Fix creation of TARGET_MEM_REFs with __capability alias pointers
    
    TARGET_MEM_REFs use the offset operand to convey two pieces
    of information: the alias type for TBAA purposes and a constant
    offset from the base.  create_mem_ref_raw was using fold_convert
    to merge the alias type with the integer offset, but that doesn't
    work when the alias type is a __capability pointer.

Diff:
---
 gcc/testsuite/gcc.target/aarch64/morello/pointer-arith-6.c | 13 +++++++++++++
 gcc/tree-ssa-address.c                                     |  3 ++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/morello/pointer-arith-6.c b/gcc/testsuite/gcc.target/aarch64/morello/pointer-arith-6.c
new file mode 100644
index 00000000000..5b014bdbc72
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/morello/pointer-arith-6.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+union U { unsigned __int128 h[10]; };
+union V { unsigned int e[10]; };
+
+int
+foo (union U *__capability p, union V *r)
+{
+  for (int i = 0; i < 10; i++)
+    if (p->h[i] != r->e[i])
+      __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c
index 2621f0b966e..1194370fa13 100644
--- a/gcc/tree-ssa-address.c
+++ b/gcc/tree-ssa-address.c
@@ -376,7 +376,8 @@ create_mem_ref_raw (tree type, tree alias_ptr_type, struct mem_address *addr,
     addr->step = NULL_TREE;
 
   if (addr->offset)
-    addr->offset = fold_convert (alias_ptr_type, addr->offset);
+    addr->offset = wide_int_to_tree (alias_ptr_type,
+				     wi::to_poly_wide (addr->offset));
   else
     addr->offset = build_int_cst (alias_ptr_type, 0);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-06 14:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06 14:45 [gcc(refs/vendors/ARM/heads/morello)] Fix creation of TARGET_MEM_REFs with __capability alias pointers Matthew Malcomson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).