[llvm-dev] Does OpenMP hints bypass the vectorisation legality check in llvm
Saito, Hideki via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 19 13:44:42 PST 2018
Let me go a little deeper. Xinmin's answer is correct but a bit over-simplified.
There are parts of "legality" and "cost model" that OpenMP SIMD code has to go through, and current LV is rather unclear about it
---- due to historical reasons ---- and I'm trying to resolve them one small step at a time.
For example, load/store masking is part of "legality" we have to enforce even for OpenMP SIMD code. Whether we run LVL.canVectorize()
or not, we still have to record such information so that correct vector code will be generated. Also, unless programmer specifies all "cost model
decisions", we still have to run cost model to fill the gap. There are many OpenMP SIMD loops w/o SIMDLEN clause ---- vectorizer needs to
decide the optimal VF for the loop.
Date: Fri, 19 Jan 2018 17:54:05 +0000
From: "Tian, Xinmin via llvm-dev" <llvm-dev at lists.llvm.org>
To: Tom Sun <ps702 at cam.ac.uk>, "llvm-dev at lists.llvm.org" <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Does OpenMP hints bypass the vectorization legality check in llvm
Tom, your understanding is correct per OpenMP SIMD model. Our implementation behaves as you stated. Which is not part of LLVM main trunk yet.
From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Tom Sun via llvm-dev
Sent: Friday, January 19, 2018 12:39 AM
To: llvm-dev at lists.llvm.org
Subject: [llvm-dev] Does OpenMP hints bypass the vectorisation legality check in llvm
I am currently looking into how "#pragma omp for simd" is actually recognized in llvm. To my knowledge, clang will parse it and set metadata in IR to indicate this force-vectorization hint and later optimization passes would read it and vectorize the marked loop. Therefore, the loop should be vectorized even the compiler think it might not be safe to do so?
So my assumption is that such force-vectorization hints should bypass both the vectorization legality and cost model check. However, in LoopVectorize.cpp, I can't see how this is done. All loops will be sent to a legality check of LVL.canVectorize() and, if this condition does not fit, it return to false directly without actually reaching the vectorization stage.
Is there anything wrong with my assumption made on the use of force-vectorization hints?
Thanks in advance,
More information about the llvm-dev