[llvm-dev] LoopVectorizer with ifconversion

Hal Finkel via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 20 13:43:31 PDT 2017


On 03/20/2017 03:59 AM, Jonas Paulsson wrote:
>
> On 2017-03-17 23:23, Renato Golin wrote:
>> On 17 March 2017 at 16:34, Hal Finkel <hfinkel at anl.gov> wrote:
>>> In general, this is true everywhere. In a large vectorized loop, 
>>> this cost
>>> may well be worthwhile. The idea is that the cost model should 
>>> account for
>>> all of these costs. If it doesn't properly, we should fix that.
>> Isn't this only worth when the SIMD instructions can be
>> conditionalised per lane? I believe AVX512 and SVE have such
>> abilities, but not NEON or SSE.
>>
>> Does SystemZ support conditionalisation in SIMD?
>>
> No, z13 has no masked vector operations. I think this is checked with 
> the isLegalMasked...() hooks. Is this implicitly assumed in 
> LoopVectorizers if-conversion algorithm somewhere? I see the scalar 
> costs are adjusted with 'ScalarCost /= getReciprocalPredBlockProb()'. 
> It seems that this should be done for all blocks that remain after 
> vectorization?
>
> If not doing the simple thing and disabling store with predication 
> vectorization, I agree with Hal that this could be worth modeling as 
> an extra cost to not reject some large loop with just one conditional 
> store, or so.
>
> I think this extra cost should be added to the compare, but I am not 
> sure if it would be better to instead add it to the branch, because 
> there are also cases of e.g. (AND (COMPARE, COMPARE)). Adding a cost 
> to a vectorized branch instead could be done by assuming that a 
> conditional branch would have to be set up for each branch after the 
> vector compare.

Yes, I'd assume that you'd want to add some relative cost of a compare, 
extract, and a correctly-predicted branch (etc.).

>
> Does the loop vectorizer know which blocks that need predication in 
> the scalar loop will remain after vectorization? SystemZ could check 
> such blocks by looking for stores, but that seems like extra work.

Yes. Legal->blockNeedsPredication (there's also 
Legal->isScalarWithPredication).

  -Hal

>
> thanks,
>
> Jonas
>

-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-dev mailing list