<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi,
<div class=""><br class="">
</div>
<div class="">I have tried couple of c test cases with llvm to see if we handle misaligned accesses, but it seems we do not have transformations to align loop accesses. Misaligned accesses can worsen performance depending on the underlying target (severity
of crossing cache line boundaries)</div>
<div class=""><br class="">
</div>
<div class="">One example:</div>
<div class="">//unaligned load and store</div>
<div class="">
<div class="">
<div class="">int foo(short *a, int m){ </div>
<div class=""> int i;</div>
<div class=""> for(i=1; i<m ; i++)</div>
<div class=""> a[i] *=2;</div>
<div class=""> return a[3];</div>
<div class="">}</div>
</div>
</div>
<div class=""><br class="">
</div>
<div class="">IR generated though clang -O3 -mllvm -disable-llvm-optzns. Passed this through opt -O3 and the loop vectorizer adds vector code for this loop, but the GEP access starts at offset 1. </div>
<div class=""><br class="">
</div>
<div class="">
<div class="">vector.body: ; preds = %vector.body, %vector.body.preheader.new</div>
<div class=""> %index = phi i64 [ 0, %vector.body.preheader.new ], [ %index.next.3, %vector.body ]</div>
<div class=""> %niter = phi i64 [ %unroll_iter, %vector.body.preheader.new ], [ %niter.nsub.3, %vector.body ]</div>
<div class=""> %offset.idx = or i64 %index, 1</div>
<div class=""> <b class=""> %9 = getelementptr inbounds i16, i16* %a, i64 %offset.idx</b></div>
<div class=""> %10 = bitcast i16* %9 to <8 x i16>*</div>
<div class=""> %wide.load = load <8 x i16>, <8 x i16>* %10, align 2, !tbaa !2</div>
<div class=""> %11 = shl <8 x i16> %wide.load, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1></div>
<div class=""> %12 = bitcast i16* %9 to <8 x i16>*</div>
<div class=""> <b class="">store <8 x i16> %11, <8 x i16>* %12, align 2, !tbaa !2</b></div>
</div>
<div class=""><br class="">
</div>
<div class="">Is there a reason we don’t support loop peeling for alignment handling? </div>
<div class=""><br class="">
</div>
<div class="">Thanks,<br class="">
<div class="">Anna </div>
<br class="">
</div>
</body>
</html>