Skip to content

Commit aac20a0

Browse files
author
Xu, Xiaohui1
committed
simplify code
1 parent 9b6e6c8 commit aac20a0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/gc/Analysis/VectorBasedFusionAnalysis.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,20 @@ static inline bool isReadOrWriteOperation(Operation *op) {
4444
}
4545

4646
/// which axis do the shape cast in source shape a
47-
void shapeCastSourceAxis(const ArrayRef<int64_t> &a, const ArrayRef<int64_t> &b,
47+
void shapeCastSourceAxis(ArrayRef<int64_t> a, ArrayRef<int64_t> b,
4848
SmallVector<int64_t> &res) {
4949
unsigned rankA = a.size();
5050
unsigned rankB = b.size();
5151
if (rankA >= rankB)
52-
llvm::llvm_unreachable_internal("May be invalid shape cast operation.");
52+
llvm_unreachable("May be invalid shape cast operation.");
5353

5454
auto isOne = [](int64_t v) { return v == 1; };
5555

5656
// Special-case for n-D to 0-d shape cast. 'b' must be all ones to be shape
5757
// casted to a 0-d vector.
5858
if (rankA == 0 && all_of(b, isOne)) {
59-
for (size_t i = 0; i < a.size(); i++) {
59+
for (size_t i = 0; i < a.size(); i++)
6060
res.emplace_back(i);
61-
}
6261
return;
6362
}
6463

@@ -71,7 +70,7 @@ void shapeCastSourceAxis(const ArrayRef<int64_t> &a, const ArrayRef<int64_t> &b,
7170
while (dimB < dimA && j < rankB)
7271
dimB *= b[j++];
7372
if (dimA != dimB) {
74-
llvm::llvm_unreachable_internal(" Invalid shape cast operation.");
73+
llvm_unreachable(" Invalid shape cast operation.");
7574
break;
7675
}
7776
if (bAxisBegin != j) {
@@ -134,11 +133,11 @@ void getOperationDataAxis(Operation *op, SmallVector<int64_t> &dataAxis) {
134133
auto dstType = shapeCastOp.getResultVectorType();
135134
auto srcShape = srcType.getShape();
136135
auto dstShape = dstType.getShape();
137-
if (srcShape.size() < dstShape.size()) {
136+
if (srcShape.size() < dstShape.size())
138137
shapeCastSourceAxis(srcShape, dstShape, dataAxis);
139-
} else {
138+
else
140139
shapeCastSourceAxis(dstShape, srcShape, dataAxis);
141-
}
140+
142141
return;
143142
})
144143
.Case<vector::BroadcastOp>([&](vector::BroadcastOp broadcastOp) {

0 commit comments

Comments
 (0)