Skip to content

Commit

Permalink
[mlir][vector] Fix invalid IR in vector.print lowering (#74410)
Browse files Browse the repository at this point in the history
`DecomposePrintOpConversion` used to generate invalid op such as:
```
error: 'arith.extsi' op operand type 'vector<10xi32>' and result type 'vector<10xi32>' are cast incompatible
  vector.print %v9 : vector<10xi32>
```

This commit fixes tests such as
`mlir/test/Integration/Dialect/Vector/CPU/test-reductions-i32.mlir` when
verifying the IR after each pattern application (#74270).
  • Loading branch information
matthias-springer authored Dec 6, 2023
1 parent 68f91cd commit 8f9aac4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,14 @@ struct DecomposePrintOpConversion : public VectorToSCFPattern<vector::PrintOp> {
auto targetVectorType = vectorType.cloneWith({}, legalIntTy);
value = rewriter.create<vector::BitCastOp>(loc, signlessSourceVectorType,
value);
if (width == 1 || intTy.isUnsigned())
value = rewriter.create<arith::ExtUIOp>(loc, signlessTargetVectorType,
value);
else
value = rewriter.create<arith::ExtSIOp>(loc, signlessTargetVectorType,
value);
if (value.getType() != signlessTargetVectorType) {
if (width == 1 || intTy.isUnsigned())
value = rewriter.create<arith::ExtUIOp>(loc, signlessTargetVectorType,
value);
else
value = rewriter.create<arith::ExtSIOp>(loc, signlessTargetVectorType,
value);
}
value = rewriter.create<vector::BitCastOp>(loc, targetVectorType, value);
vectorType = targetVectorType;
}
Expand Down

0 comments on commit 8f9aac4

Please sign in to comment.