Skip to content

Commit 9ba9d44

Browse files
committed
Fix bugs
1 parent f4a3fb4 commit 9ba9d44

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,17 +1118,14 @@ class VectorExtractOpConversion
11181118
// Since the LLVM type converter converts 0-d vectors to 1-d vectors, we
11191119
// need to add a position for this change.
11201120
if (extractOp.getSourceVectorType().getRank() == 0) {
1121-
auto idxType = rewriter.getIndexType();
1122-
Value position = rewriter.create<LLVM::ConstantOp>(
1123-
loc, typeConverter->convertType(idxType),
1124-
rewriter.getIntegerAttr(idxType, 0));
1125-
positionVec.push_back(position);
1121+
Type idxType = typeConverter->convertType(rewriter.getIndexType());
1122+
positionVec.push_back(rewriter.getZeroAttr(idxType));
11261123
}
11271124

11281125
Value extracted = adaptor.getVector();
1129-
if (extractsScalar) {
1126+
if (extractsAggregate) {
11301127
ArrayRef<OpFoldResult> position(positionVec);
1131-
if (extractsAggregate) {
1128+
if (extractsScalar) {
11321129
// If we are extracting a scalar from the extracted member, we drop
11331130
// the last index, which will be used to extract the scalar out of the
11341131
// vector.

mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ func.func @extract_scalar_from_vec_0d_index(%arg0: vector<index>) -> index {
13441344
// CHECK-LABEL: @extract_scalar_from_vec_0d_index(
13451345
// CHECK-SAME: %[[A:.*]]: vector<index>)
13461346
// CHECK: %[[T0:.*]] = builtin.unrealized_conversion_cast %[[A]] : vector<index> to vector<1xi64>
1347-
// CHECK: %[[T1:.*]] = llvm.mlir.constant(0 : index) : i64
1347+
// CHECK: %[[T1:.*]] = llvm.mlir.constant(0 : i64) : i64
13481348
// CHECK: %[[T2:.*]] = llvm.extractelement %[[T0]][%[[T1]] : i64] : vector<1xi64>
13491349
// CHECK: %[[T3:.*]] = builtin.unrealized_conversion_cast %[[T2]] : i64 to index
13501350
// CHECK: return %[[T3]] : index

0 commit comments

Comments
 (0)