XCore target: disable vectorization

Arnold Schwaighofer aschwaighofer at apple.com
Mon Sep 9 09:21:51 PDT 2013


The api is meant to handle scalar and vector:

  /// \return The number of scalar or vector registers that the target has.
  /// If 'Vectors' is true, it returns the number of vector registers. If it is
  /// set to false, it returns the number of scalar registers.
  virtual unsigned getNumberOfRegisters(bool Vector) const;

We don’t actually use the number of scalar registers anywhere and this number would depend on the (dominant) type (so would the vector number).

I think, we can revisit this when we revisit the unrolling heuristic in the loop vectorizer (I have a radar for this, it is just not my highest priority).

 
On Sep 9, 2013, at 11:05 AM, Eric Christopher <echristo at gmail.com> wrote:

> Drive by comment, should probably be "getNumberOfVectorRegisters" or
> some sort of query with vector in the name :)
> 
> -eric
> 
> On Mon, Sep 9, 2013 at 8:43 AM, Arnold Schwaighofer
> <aschwaighofer at apple.com> wrote:
>> Hi Robert,
>> 
>> I think Nadav meant to add code to the LoopVectorizer and SLPVectorizer that calls "TTI.getNumberOfRegisters(true)” and stops vectorization if it returns 0. Something like:
>> 
>> --- a/lib/Transforms/Vectorize/LoopVectorize.cpp
>> +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp
>> @@ -906,6 +906,11 @@ struct LoopVectorize : public LoopPass {
>>     DT = &getAnalysis<DominatorTree>();
>>     TLI = getAnalysisIfAvailable<TargetLibraryInfo>();
>> 
>> +    // If the target claims to have no vector registers don't attempt
>> +    // vectorization.
>> +    if (!TTI->getNumberOfRegisters(true))
>> +      return false;
>> +
>>     if (DL == NULL) {
>>       DEBUG(dbgs() << "LV: Not vectorizing because of missing data layout");
>>       return false;
>> 
>> 
>> 
>> diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp
>> index 1f288bc..6ddcc51 100644
>> --- a/lib/Transforms/Vectorize/SLPVectorizer.cpp
>> +++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp
>> @@ -1565,6 +1565,11 @@ struct SLPVectorizer : public FunctionPass {
>>     if (!DL)
>>       return false;
>> 
>> +    // If the target claims to have no vector registers don't attempt
>> +    // vectorization.
>> +    if (!TTI->getNumberOfRegisters(true))
>> +      return false;
>> +
>>     // Don't vectorize when the attribute NoImplicitFloat is used.
>>     if (F.hasFnAttribute(Attribute::NoImplicitFloat))
>>       return false;
>> 
>> On Sep 9, 2013, at 7:13 AM, Robert Lytton <robert at xmos.com> wrote:
>> 
>>> Hi Rafael, Nadav,
>>> 
>>> Thank you for the input but I don't follow where the change needs to be made.
>>> 
>>> Are you suggesting changes to llvm's  lib/Transforms/IPO/PassManagerBuilder.cpp?
>>> This approach would  make the '-vectorize-loops' & '-vectorize-slp' flags  only relevant for targets with vector registers?
>>> 
>>> Or in clang/lib/Driver/Tools.cpp?
>>> 
>>> In either case, I can't see how to get hold of the TargetTransformInfo cleanly.
>>> 
>>> Robert
>>> 
>>> ________________________________________
>>> From: Rafael Espíndola [rafael.espindola at gmail.com]
>>> Sent: 06 September 2013 18:43
>>> To: Nadav Rotem
>>> Cc: Robert Lytton; cfe-commits at cs.uiuc.edu; Arnold Schwaighofer
>>> Subject: Re: XCore target: disable vectorization
>>> 
>>>> unsigned TargetVectorRegisters = TTI.getNumberOfRegisters(true);
>>> 
>>> And not vectorize if the target says 0? I like that idea.
>>> 
>>> Cheers,
>>> Rafael
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list