<div dir="ltr">We don't need to check the distance between op and src explicitly.<div><br></div><div>%13 is more or less %len, but it takes some edge cases into account.<br></div><div>Ignoring those edge cases, to determine overlap, we check (%op <= %src + %len) && (%src <= %op + %len).<br></div><div><br></div><div>Let's assume the ranges [%op, %op + %len] and [%src, %src + %len] overlap.</div><div>If %op <= %src, then (%op <= %src + %len) obviously holds. But then, since they overlap, %src must start somewhere in [%op, %op + %len], so (%src <= %op + %len), and the condition we check is true.</div><div>The %src <= %op case is symmetrical.</div><div><br></div><div>As Adam said, it's possible that the actual calculation we use has an off-by-one somewhere. I'm pretty sure my explanation above does. :-)</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 2, 2016 at 11:16 AM, Demikhovsky, Elena via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Right. As you see, the distance between %op and %src is not checked.<br>
%bound0 is some arithmetic between %op and %len<br>
And<br>
%bound1 is some arithmetic between %src and %len<br>
<br>
The loop just for the reference:<br>
<span class=""> while (len > 0) {<br>
*(reinterpret_cast<long long*>(op)) = *(reinterpret_cast<const long long*>(src));<br>
src += 8;<br>
op += 8;<br>
len -= 8;<br>
}<br>
<br>
</span>- Elena<br>
<div><div class="h5"><br>
><br>
>mkuper added a comment.<br>
><br>
>I tried building with r274114 (before this was reverted), and we did<br>
>generate a runtime alias check:<br>
><br>
> vector.memcheck: ; preds = %min.iters.checked<br>
> %7 = sub i32 -1, %len<br>
> %8 = icmp sgt i32 %7, -9<br>
> %smax9 = select i1 %8, i32 %7, i32 -9<br>
> %9 = add i32 %len, %smax9<br>
> %10 = add i32 %9, 8<br>
> %11 = lshr i32 %10, 3<br>
> %12 = zext i32 %11 to i64<br>
> %13 = shl i64 %12, 3<br>
> %scevgep = getelementptr i8, i8* %op, i64 %13<br>
> %scevgep10 = getelementptr i8, i8* %src, i64 %13<br>
> %bound0 = icmp ule i8* %op, %scevgep10<br>
> %bound1 = icmp ule i8* %src, %scevgep<br>
> %found.conflict = and i1 %bound0, %bound1<br>
> %memcheck.conflict = and i1 %found.conflict, true<br>
> %cast.crd = trunc i64 %n.vec to i32<br>
> %14 = shl i32 %cast.crd, 3<br>
> %ind.end = sub i32 %len, %14<br>
> %15 = shl i64 %n.vec, 3<br>
> %ind.end12 = getelementptr i8, i8* %op, i64 %15<br>
> %ind.end14 = getelementptr i8, i8* %src, i64 %15<br>
> br i1 %memcheck.conflict, label %<a href="http://scalar.ph" rel="noreferrer" target="_blank">scalar.ph</a>, label %<a href="http://vector.ph" rel="noreferrer" target="_blank">vector.ph</a><br>
><br>
>I'm not sure this runtime check is correct, though.<br>
><br>
><br>
>Repository:<br>
> rL LLVM<br>
><br>
><a href="https://reviews.llvm.org/D20789" rel="noreferrer" target="_blank">https://reviews.llvm.org/D20789</a><br>
><br>
><br>
<br>
</div></div>---------------------------------------------------------------------<br>
Intel Israel (74) Limited<br>
<br>
This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>