Even I change acc[i] += to acc[i] in the original example, gcc still generates versioning due to alias. So it clearly behave differently from scalar code aliasing analysis.
tst3.c:12: note: versioning for alias required: can't determine dependence between _10->real and *_7 tst3.c:12: note: mark for run-time aliasing test between _10->real and *_7 tst3.c:12: note: versioning for alias required: can't determine dependence Bingfeng -----Original Message----- From: Richard Biener [mailto:rguent...@suse.de] Sent: 03 February 2014 10:35 To: Jakub Jelinek Cc: Bingfeng Mei; gcc@gcc.gnu.org Subject: Re: No TBAA before ptr_derefs_may_alias_p? On Mon, 3 Feb 2014, Richard Biener wrote: > And note that for the case in question we > can derive non-aliasing because with > > p[i] += q[i]; > > p[i] is both read _and_ written in the same iteration thus > it cannot have the dynamic type of q[i] before it's stored > into. Of course data-dependence doesn't do this kind of > analysis currently, but it certainly could. The vectorizer already has code to analyzes data-refs for groups, not for read-write of the same loc as needed here, so it could be reasonably easy to extend its analysis to detect this case and mark the write DR with a flag so that in vect_analyze_data_ref_dependence the _vectorizer_ could apply TBAA to disambiguate the two DRs. Richard.