This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Aliasing: look through pointer's def stmt
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: Jeff Law <law at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 4 Nov 2013 14:49:38 +0100
- Subject: Re: Aliasing: look through pointer's def stmt
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1310250707430 dot 14734 at stedding dot saclay dot inria dot fr> <526A0269 dot 8030407 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1310250809590 dot 4165 at laptop-mg dot saclay dot inria dot fr> <CAFiYyc27=sN1itn+N09rpmm8tWGt-Khu7oASLd0ODsdZh=ofzw at mail dot gmail dot com> <CAFiYyc2EtayY0tiW1pz4t-zf0uVC24UcF5s7yaUrY3f7_jxoVg at mail dot gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1310251123350 dot 8620 at laptop-mg dot saclay dot inria dot fr> <CAFiYyc2WmH4WNZ7h8-8iC_6mSO50PdLNLxNzQOYZrYEvn1oQkQ at mail dot gmail dot com> <alpine dot DEB dot 2 dot 02 dot 1310251852480 dot 9786 at stedding dot saclay dot inria dot fr> <alpine dot DEB dot 2 dot 10 dot 1310261838280 dot 15626 at laptop-mg dot saclay dot inria dot fr> <CAFiYyc3dZr1DrQV7X+6kN=eFFx7CKNhbHOdBgqt_bWLp0xe07w at mail dot gmail dot com> <alpine dot DEB dot 2 dot 02 dot 1310300102500 dot 21750 at stedding dot saclay dot inria dot fr> <CAFiYyc0=UP2RTdfoR9pDTSo4RnaLnXOQS8O0QP51gfKz4UmnvQ at mail dot gmail dot com> <alpine dot DEB dot 2 dot 02 dot 1310311752160 dot 5593 at stedding dot saclay dot inria dot fr>
On Thu, Oct 31, 2013 at 6:11 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Wed, 30 Oct 2013, Richard Biener wrote:
>
>>> --- gcc/tree-ssa-alias.c (revision 204188)
>>> +++ gcc/tree-ssa-alias.c (working copy)
>>> @@ -567,20 +567,29 @@ void
>>> ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
>>> {
>>> HOST_WIDE_INT t1, t2;
>>> ref->ref = NULL_TREE;
>>> if (TREE_CODE (ptr) == SSA_NAME)
>>> {
>>> gimple stmt = SSA_NAME_DEF_STMT (ptr);
>>> if (gimple_assign_single_p (stmt)
>>> && gimple_assign_rhs_code (stmt) == ADDR_EXPR)
>>> ptr = gimple_assign_rhs1 (stmt);
>>> + else if (is_gimple_assign (stmt)
>>> + && gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR
>>> + && host_integerp (gimple_assign_rhs2 (stmt), 0)
>>> + && (t1 = int_cst_value (gimple_assign_rhs2 (stmt))) >= 0)
>>
>>
>> No need to restrict this to positive offsets I think.
>
>
> Here is the follow-up patch to remove this restriction (bootstrap+testsuite
> on x86_64-unknown-linux-gnu).
> I don't really know how safe it is.
>
> I couldn't use host_integerp(,1) since it returns false for (size_t)(-1) on
> x86_64, and host_integerp(,0) seemed strange, but I could use it if you
> want.
Well, host_integer_p (, 0) looks correct to me. But ...
> Index: gcc/tree-ssa-alias.h
> ===================================================================
> --- gcc/tree-ssa-alias.h (revision 204267)
> +++ gcc/tree-ssa-alias.h (working copy)
> @@ -139,30 +139,30 @@ extern void pt_solution_set_var (struct
>
> extern void dump_pta_stats (FILE *);
>
> extern GTY(()) struct pt_solution ipa_escaped_pt;
>
> /* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2]
> overlap. SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the
> range is open-ended. Otherwise return false. */
>
> static inline bool
> -ranges_overlap_p (unsigned HOST_WIDE_INT pos1,
> - unsigned HOST_WIDE_INT size1,
> - unsigned HOST_WIDE_INT pos2,
> - unsigned HOST_WIDE_INT size2)
> +ranges_overlap_p (HOST_WIDE_INT pos1,
> + HOST_WIDE_INT size1,
> + HOST_WIDE_INT pos2,
> + HOST_WIDE_INT size2)
I think size[12] should still be unsigned (we don't allow negative
sizes but only the special value -1U which we special-case only to
avoid pos + size to wrap)
Otherwise ok.
Thanks,
Richard.
> {
> if (pos1 >= pos2
> - && (size2 == (unsigned HOST_WIDE_INT)-1
> + && (size2 == -1
> || pos1 < (pos2 + size2)))
> return true;
> if (pos2 >= pos1
> - && (size1 == (unsigned HOST_WIDE_INT)-1
> + && (size1 == -1
> || pos2 < (pos1 + size1)))
> return true;
>
> return false;
> }
>
>
> #endif /* TREE_SSA_ALIAS_H */
>