From ebcc3d93d863c046375534bd8d7526472cd4e239 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 1 Nov 2009 22:12:07 +0000 Subject: [PATCH] tree.def (TARGET_MEM_REF): Update comment. * tree.def (TARGET_MEM_REF): Update comment. * alias.c (get_alias_set): Retrieve the original memory reference for a TARGET_MEM_REF before proceeding. From-SVN: r153796 --- gcc/ChangeLog | 6 ++++++ gcc/alias.c | 7 ++++++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/opt5.adb | 21 +++++++++++++++++++++ gcc/tree.def | 4 ++-- 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/opt5.adb diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 94a1ccb169e..b4e1bff0845 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-11-01 Eric Botcazou + + * tree.def (TARGET_MEM_REF): Update comment. + * alias.c (get_alias_set): Retrieve the original memory reference for + a TARGET_MEM_REF before proceeding. + 2009-10-31 Anatoly Sokolov * config/frv/frv.c (frv_function_value, frv_libcall_value, diff --git a/gcc/alias.c b/gcc/alias.c index 1d4290f7848..cdfa6d2d3ac 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -640,7 +640,7 @@ get_alias_set (tree t) aren't types. */ if (! TYPE_P (t)) { - tree inner = t; + tree inner; /* Remove any nops, then give the language a chance to do something with this tree before we look at it. */ @@ -649,8 +649,13 @@ get_alias_set (tree t) if (set != -1) return set; + /* Retrieve the original memory reference if needed. */ + if (TREE_CODE (t) == TARGET_MEM_REF) + t = TMR_ORIGINAL (t); + /* First see if the actual object referenced is an INDIRECT_REF from a restrict-qualified pointer or a "void *". */ + inner = t; while (handled_component_p (inner)) { inner = TREE_OPERAND (inner, 0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bd400052ad4..a6bf61b6b73 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-11-01 Eric Botcazou + + * gnat.dg/opt5.adb: New test. + 2009-11-01 Tobias Burnus PR fortran/41872 diff --git a/gcc/testsuite/gnat.dg/opt5.adb b/gcc/testsuite/gnat.dg/opt5.adb new file mode 100644 index 00000000000..73a21bde023 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt5.adb @@ -0,0 +1,21 @@ +-- { dg-do run } +-- { dg-options "-O2" } + +procedure Opt5 is + + type Varray is array (1 .. 4) of Natural; + + procedure Check_All_Ones (A : Varray) is + begin + for J in A'Range loop + if (A (J)) /= 1 then + raise Program_Error; + end if; + end loop; + end; + + X : constant Varray := (1, 1, 1, 1); + +begin + Check_All_Ones (X); +end; diff --git a/gcc/tree.def b/gcc/tree.def index 74470b5783a..01d9b3060de 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -967,9 +967,9 @@ DEFTREECODE (REALIGN_LOAD_EXPR, "realign_load", tcc_expression, 3) The type of STEP, INDEX and OFFSET is sizetype. The type of BASE is sizetype or a pointer type (if SYMBOL is NULL). - + The sixth argument is the reference to the original memory access, which - is preserved for the purposes of the RTL alias analysis. */ + is preserved for the purpose of alias analysis. */ DEFTREECODE (TARGET_MEM_REF, "target_mem_ref", tcc_reference, 6) -- 2.30.2