llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.8k stars 10.98k forks source link

What attributes can be added to libc++ algorithms to help the auto-vectorizer #96241

Open hiraditya opened 2 weeks ago

hiraditya commented 2 weeks ago

Can adding attributes to libc++ algorithms to help the auto-vectorizer? e.g.,

@fhahn suggested parallel stl can also use some attributes https://libcxx.llvm.org/Status/PSTL.html.

philnik777 commented 2 weeks ago

I'm not sure where you'd assume alignment, and I'm not aware of any major performance problems due to aliasing. The main problem the auto vectorizer has is that it doesn't know that loops where we might break out can still dereference elements past that point, making it block auto vectorization.

hiraditya commented 1 week ago

I'm not sure where you'd assume alignment, and I'm not aware of any major performance problems due to aliasing.

i see. are there any attributes you think may help here.

The main problem the auto vectorizer has is that it doesn't know that loops where we might break out can still dereference elements past that point, making it block auto vectorization.

Are you referring to algorithms like all_of, none_of etc.?

philnik777 commented 1 day ago

I'm not sure where you'd assume alignment, and I'm not aware of any major performance problems due to aliasing.

i see. are there any attributes you think may help here.

I'm not aware of any that already exist. Otherwise I would have tried adding them already.

The main problem the auto vectorizer has is that it doesn't know that loops where we might break out can still dereference elements past that point, making it block auto vectorization.

Are you referring to algorithms like all_of, none_of etc.?

Yes, exactly.