Skip to content

Commit bad7d6b

Browse files
author
Francesco Petrogalli
committed
Revert "[llvm][LV] Replace unsigned VF with ElementCount VF [NFCI]"
Reverting because the commit message doesn't reflect the one agreed on phabricator at https://reviews.llvm.org/D85794. This reverts commit c8d2b06.
1 parent e1644a3 commit bad7d6b

File tree

9 files changed

+335
-491
lines changed

9 files changed

+335
-491
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ class IntrinsicCostAttributes {
128128

129129
IntrinsicCostAttributes(Intrinsic::ID Id, const CallBase &CI,
130130
unsigned Factor);
131-
IntrinsicCostAttributes(Intrinsic::ID Id, const CallBase &CI,
132-
ElementCount Factor)
133-
: IntrinsicCostAttributes(Id, CI, Factor.Min) {
134-
assert(!Factor.Scalable);
135-
}
136131

137132
IntrinsicCostAttributes(Intrinsic::ID Id, const CallBase &CI,
138133
unsigned Factor, unsigned ScalarCost);

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,13 @@ namespace Intrinsic {
300300
typedef unsigned ID;
301301
}
302302

303-
/// A helper function for converting Scalar types to vector types. If
304-
/// the incoming type is void, we return void. If the EC represents a
305-
/// scalar, we return the scalar type.
306-
inline Type *ToVectorTy(Type *Scalar, ElementCount EC) {
307-
if (Scalar->isVoidTy() || EC.isScalar())
303+
/// A helper function for converting Scalar types to vector types.
304+
/// If the incoming type is void, we return void. If the VF is 1, we return
305+
/// the scalar type.
306+
inline Type *ToVectorTy(Type *Scalar, unsigned VF, bool isScalable = false) {
307+
if (Scalar->isVoidTy() || VF == 1)
308308
return Scalar;
309-
return VectorType::get(Scalar, EC);
310-
}
311-
312-
inline Type *ToVectorTy(Type *Scalar, unsigned VF) {
313-
return ToVectorTy(Scalar, ElementCount::getFixed(VF));
309+
return VectorType::get(Scalar, ElementCount::get(VF, isScalable));
314310
}
315311

316312
/// Identify if the intrinsic is trivially vectorizable.

llvm/include/llvm/IR/DiagnosticInfo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "llvm/ADT/Twine.h"
2222
#include "llvm/IR/DebugLoc.h"
2323
#include "llvm/Support/CBindingWrapping.h"
24-
#include "llvm/Support/TypeSize.h"
2524
#include "llvm/Support/YAMLTraits.h"
2625
#include <algorithm>
2726
#include <cstdint>
@@ -435,7 +434,6 @@ class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithLocationBase {
435434
Argument(StringRef Key, unsigned N);
436435
Argument(StringRef Key, unsigned long N);
437436
Argument(StringRef Key, unsigned long long N);
438-
Argument(StringRef Key, ElementCount EC);
439437
Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {}
440438
Argument(StringRef Key, DebugLoc dl);
441439
};

llvm/include/llvm/Support/TypeSize.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,33 +67,8 @@ class ElementCount {
6767
static ElementCount get(unsigned Min, bool Scalable) {
6868
return {Min, Scalable};
6969
}
70-
71-
/// Printing function.
72-
void print(raw_ostream &OS) const {
73-
if (Scalable)
74-
OS << "vscale x ";
75-
OS << Min;
76-
}
77-
/// Counting predicates.
78-
///
79-
/// Notice that Min = 1 and Scalable = true is considered more than
80-
/// one element.
81-
///
82-
///@{ No elements..
83-
bool isZero() const { return Min == 0; }
84-
/// Exactly one element.
85-
bool isScalar() const { return !Scalable && Min == 1; }
86-
/// One or more elements.
87-
bool isVector() const { return (Scalable && Min != 0) || Min > 1; }
88-
///@}
8970
};
9071

91-
/// Stream operator function for `ElementCount`.
92-
inline raw_ostream &operator<<(raw_ostream &OS, const ElementCount &EC) {
93-
EC.print(OS);
94-
return OS;
95-
}
96-
9772
// This class is used to represent the size of types. If the type is of fixed
9873
// size, it will represent the exact size. If the type is a scalable vector,
9974
// it will represent the known minimum size.

llvm/lib/IR/DiagnosticInfo.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,6 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
213213
unsigned long long N)
214214
: Key(std::string(Key)), Val(utostr(N)) {}
215215

216-
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
217-
ElementCount EC)
218-
: Key(std::string(Key)) {
219-
raw_string_ostream OS(Val);
220-
EC.print(OS);
221-
}
222-
223216
DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, DebugLoc Loc)
224217
: Key(std::string(Key)), Loc(Loc) {
225218
if (Loc) {

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,12 @@ class VPBuilder {
172172
/// Information about vectorization costs
173173
struct VectorizationFactor {
174174
// Vector width with best cost
175-
ElementCount Width;
175+
unsigned Width;
176176
// Cost of the loop with that width
177177
unsigned Cost;
178178

179179
// Width 1 means no vectorization, cost 0 means uncomputed cost.
180-
static VectorizationFactor Disabled() {
181-
return {ElementCount::getFixed(1), 0};
182-
}
180+
static VectorizationFactor Disabled() { return {1, 0}; }
183181

184182
bool operator==(const VectorizationFactor &rhs) const {
185183
return Width == rhs.Width && Cost == rhs.Cost;
@@ -229,10 +227,7 @@ class LoopVectorizationPlanner {
229227
/// A builder used to construct the current plan.
230228
VPBuilder Builder;
231229

232-
/// The best number of elements of the vector types used in the
233-
/// transformed loop. BestVF = None means that vectorization is
234-
/// disabled.
235-
Optional<ElementCount> BestVF = None;
230+
unsigned BestVF = 0;
236231
unsigned BestUF = 0;
237232

238233
public:
@@ -247,14 +242,14 @@ class LoopVectorizationPlanner {
247242

248243
/// Plan how to best vectorize, return the best VF and its cost, or None if
249244
/// vectorization and interleaving should be avoided up front.
250-
Optional<VectorizationFactor> plan(ElementCount UserVF, unsigned UserIC);
245+
Optional<VectorizationFactor> plan(unsigned UserVF, unsigned UserIC);
251246

252247
/// Use the VPlan-native path to plan how to best vectorize, return the best
253248
/// VF and its cost.
254-
VectorizationFactor planInVPlanNativePath(ElementCount UserVF);
249+
VectorizationFactor planInVPlanNativePath(unsigned UserVF);
255250

256251
/// Finalize the best decision and dispose of all other VPlans.
257-
void setBestPlan(ElementCount VF, unsigned UF);
252+
void setBestPlan(unsigned VF, unsigned UF);
258253

259254
/// Generate the IR code for the body of the vectorized loop according to the
260255
/// best selected VPlan.
@@ -269,7 +264,7 @@ class LoopVectorizationPlanner {
269264
/// \p Predicate on Range.Start, possibly decreasing Range.End such that the
270265
/// returned value holds for the entire \p Range.
271266
static bool
272-
getDecisionAndClampRange(const std::function<bool(ElementCount)> &Predicate,
267+
getDecisionAndClampRange(const std::function<bool(unsigned)> &Predicate,
273268
VFRange &Range);
274269

275270
protected:

0 commit comments

Comments
 (0)