XCore target: disable vectorization
Robert Lytton
robert at xmos.com
Mon Sep 9 09:15:41 PDT 2013
Hi Arnold,
Thank you.
I did ponder about stopping later, but it seemed sensible/reasonable to stop it earlier but not creating the passes.
I'll make a suitable patch for review...
I am curious to know why the TargetTransformInfo is only available via getAnalysis<> (which is only callable during passes?)
and the SelectionDAG::getTargetTransformInfo()
Robert
________________________________________
From: Arnold Schwaighofer [aschwaighofer at apple.com]
Sent: 09 September 2013 16:43
To: Robert Lytton
Cc: Rafael Espíndola; Nadav Rotem; cfe-commits at cs.uiuc.edu
Subject: Re: XCore target: disable vectorization
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