[Mlir-commits] [mlir] [mlir][arith] Add result pretty printing for constant vscale values (PR #83565)
Benjamin Maxwell
llvmlistbot at llvm.org
Tue Apr 2 08:29:24 PDT 2024
================
@@ -400,6 +400,35 @@ OpFoldResult arith::MulIOp::fold(FoldAdaptor adaptor) {
[](const APInt &a, const APInt &b) { return a * b; });
}
+void arith::MulIOp::getAsmResultNames(
+ function_ref<void(Value, StringRef)> setNameFn) {
+ if (!isa<IndexType>(getType()))
+ return;
+
+ // Match vector.vscale by name to avoid depending on the vector dialect (which
+ // is a circular dependency).
+ auto isVscale = [](Operation *op) {
+ return op && op->getName().getStringRef() == "vector.vscale";
+ };
+
+ // Name `base * vscale` or `vscale * base` as `c<base_value>_vscale`.
+ IntegerAttr baseValue;
+ if (matchPattern(getLhs(), m_Constant(&baseValue)) &&
+ isVscale(getRhs().getDefiningOp())) {
+ // base * vscale
+ } else if (isVscale(getLhs().getDefiningOp()) &&
+ matchPattern(getRhs(), m_Constant(&baseValue))) {
+ // vscale * base
+ } else {
+ return;
+ }
----------------
MacDue wrote:
I personally find the checks much more readable when kept separate.
https://github.com/llvm/llvm-project/pull/83565
More information about the Mlir-commits
mailing list