[m_Constant] Check #operands/results before hasTrait()
authorChris Lattner <clattner@nondot.org>
Mon, 15 Mar 2021 01:41:13 +0000 (18:41 -0700)
committerChris Lattner <clattner@nondot.org>
Mon, 15 Mar 2021 03:14:19 +0000 (20:14 -0700)
commit91a6ad5ad887a16e361338303d4ff3d29dba5e10
tree70fc9561f8645ab947510364469c12e8be87c372
parenta81dff1e58390ccd438b9d5ffeb289783f2ccd29
[m_Constant] Check #operands/results before hasTrait()

We know that all ConstantLike operations have one result and no operands,
so check this first before doing the trait check.  This change speeds up
Canonicalize on a CIRCT testcase by ~5%.

Differential Revision: https://reviews.llvm.org/D98615
mlir/include/mlir/IR/Matchers.h
mlir/lib/Transforms/Utils/FoldUtils.cpp