Restrict now doesn't work for tree-data-ref for non-parm_decl
Zdenek Dvorak
rakdver@kam.mff.cuni.cz
Sat Jun 9 17:30:00 GMT 2007
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
More information about the Gcc-patches
mailing list