This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Restrict now doesn't work for tree-data-ref for non-parm_decl
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: Daniel Berlin <dberlin at dberlin dot org>
- Cc: Zdenek Dvorak <rakdver at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>, gangren at google dot com
- Date: Sat, 9 Jun 2007 19:29:09 +0200
- Subject: Re: Restrict now doesn't work for tree-data-ref for non-parm_decl
- References: <4aca3dc20706091014v6b1e5e0ap9823b1cea8873cdd@mail.gmail.com>
Hello,
> your recent rework of tree-data-ref.c broke determining non-dependence
> of src1row and src2row in the following testcase:
>
> void cvSubInPlace_8bit(short *src1[], short *src2[], int height, int
> num_in_row) {
> for(int y=0; y<height; y++) {
> short* __restrict src1row = src1[y];
> short* __restrict src2row = src2[y];
>
> for(int i=num_in_row; i--;) {
> *src1row -= *src2row;
> ++src1row;
> ++src2row;
> }
> }
> }
>
> The problem is you added
>
> if (TYPE_RESTRICT (type_a) && TYPE_RESTRICT (type_b)
> && (!DR_IS_READ (a) || !DR_IS_READ (b))
> && decl_a && TREE_CODE (decl_a) == PARM_DECL
> && decl_b && TREE_CODE (decl_b) == PARM_DECL
> && TREE_CODE (DECL_CONTEXT (decl_a)) == FUNCTION_DECL
> && DECL_CONTEXT (decl_a) == DECL_CONTEXT (decl_b))
> ^^^^^^^^^^^^^^^^^^^^^
> The PARM_DECL checks above to our usage of restrict info.
>
> If I replace them with DECL_P, the dependence is correctly determined again.
>
> Is there some reason you believe there is a difference between
> restrict on var_decl vs restrict on parm_decl?
> I could understrand if the check was for DECL_P, but i can't see why
> PARM_DECL is special here.
actually, I did not change anything here; the original check was
- else if (TYPE_RESTRICT (type_a)
- && TYPE_RESTRICT (type_b)
- && (!DR_IS_READ (drb) || !DR_IS_READ (dra))
- && TREE_CODE (DR_BASE_ADDRESS (dra)) == SSA_NAME
- && (decl_a = SSA_NAME_VAR (DR_BASE_ADDRESS (dra)))
- && TREE_CODE (decl_a) == PARM_DECL
- && TREE_CODE (DECL_CONTEXT (decl_a)) == FUNCTION_DECL
- && TREE_CODE (DR_BASE_ADDRESS (drb)) == SSA_NAME
- && (decl_b = SSA_NAME_VAR (DR_BASE_ADDRESS (drb)))
- && TREE_CODE (decl_b) == PARM_DECL
- && TREE_CODE (DECL_CONTEXT (decl_b)) == FUNCTION_DECL
- && DECL_CONTEXT (decl_a) == DECL_CONTEXT (decl_b))
Which also passes only for PARM_DECLs. I do not understand things well
enough to say whether restricting this to PARM_DECLs is necessary or not.
> Also, i believe the check should probably additionally be decl_a !=
> decl_b in any case, since otherwise, we will claim things whose base
> object is the same restricted pointer don't alias, even if they have
> the same offset, etc.
Yes, you are right.
Zdenek