hameeza ahmed via llvm-dev
2017-Nov-10 21:24 UTC
[llvm-dev] unable to vectorize copy statement
Hello, I am trying to vectorize copy statement in LLVM but unable to do so why? my code is follows: int main() { int c[2048], a[2048]; for (int j=0; j<2048; j++) { a[j]=2; c[j] = a[j]; } } the command is follows: opt -S -O3 -force-vector-width=64 s.ll -o s_o3.ll how to do this? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171111/063bb9d4/attachment.html>
Craig Topper via llvm-dev
2017-Nov-11 01:01 UTC
[llvm-dev] unable to vectorize copy statement
Nothing uses the array after the loop and the program exits after that. Thus the compiler optimized out the loop because the computation was unnecessary. It had not affect on the observable behavior of the program. ~Craig On Fri, Nov 10, 2017 at 1:24 PM, hameeza ahmed <hahmed2305 at gmail.com> wrote:> Hello, > I am trying to vectorize copy statement in LLVM but unable to do so why? > my code is follows: > > int main() > > { > > int c[2048], a[2048]; > > for (int j=0; j<2048; j++) > > { a[j]=2; > c[j] = a[j]; > > } > } > > the command is follows: > opt -S -O3 -force-vector-width=64 s.ll -o s_o3.ll > > how to do this? >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171110/886a8a32/attachment.html>
Stephen Checkoway via llvm-dev
2017-Nov-11 17:54 UTC
[llvm-dev] unable to vectorize copy statement
> On Nov 10, 2017, at 15:24, hameeza ahmed via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hello, > I am trying to vectorize copy statement in LLVM but unable to do so why? my code is follows: > > int main() > > { > > int c[2048], a[2048]; > > for (int j=0; j<2048; j++) > > { a[j]=2; > c[j] = a[j]; > > } > } > > the command is follows: > opt -S -O3 -force-vector-width=64 s.ll -o s_o3.ll > > how to do this?This seems to work, although I'm not entirely sure about the -force-vector-width=64. https://godbolt.org/g/oqzaHR -- Stephen Checkoway