XCore target: disable vectorization

Arnold Schwaighofer aschwaighofer at apple.com
Mon Sep 9 08:43:24 PDT 2013


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





More information about the cfe-commits mailing list