Skip to content

Commit 1584f58

Browse files
committed
Addressing further code review comments
Signed-off-by: Mohammadreza Ameri Mahabadian <[email protected]>
1 parent a368eb7 commit 1584f58

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

mlir/lib/Dialect/SPIRV/Transforms/ConvertToReplicatedConstantCompositePass.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ static Type getArrayElemType(Attribute attr) {
3636

3737
static std::pair<Attribute, uint32_t>
3838
getSplatAttrAndNumElements(Attribute valueAttr, Type valueType) {
39-
Attribute attr;
40-
uint32_t numElements = 1;
41-
4239
auto compositeType = dyn_cast_or_null<spirv::CompositeType>(valueType);
4340
if (!compositeType)
4441
return {nullptr, 1};
@@ -49,19 +46,21 @@ getSplatAttrAndNumElements(Attribute valueAttr, Type valueType) {
4946

5047
if (auto arrayAttr = dyn_cast<ArrayAttr>(valueAttr)) {
5148
if (llvm::all_equal(arrayAttr)) {
52-
attr = arrayAttr[0];
53-
numElements = arrayAttr.size();
49+
Attribute attr = arrayAttr[0];
50+
uint32_t numElements = arrayAttr.size();
5451

5552
// Find the inner-most splat value for array of composites
5653
auto [newAttr, newNumElements] =
5754
getSplatAttrAndNumElements(attr, getArrayElemType(attr));
5855
if (newAttr) {
59-
return {newAttr, numElements * newNumElements};
56+
attr = newAttr;
57+
numElements *= newNumElements;
6058
}
59+
return {attr, numElements};
6160
}
6261
}
6362

64-
return {attr, numElements};
63+
return {nullptr, 1};
6564
}
6665

6766
struct ConstantOpConversion final : OpRewritePattern<spirv::ConstantOp> {

0 commit comments

Comments
 (0)