[clang] [CIR] Attempt to fold casts and unary ops during codegen (PR #175675)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 13 09:40:24 PST 2026
================
@@ -66,6 +66,17 @@ struct RemoveRedundantBranches : public OpRewritePattern<BrOp> {
}
};
+struct RemoveUnusedConstants : public OpRewritePattern<ConstantOp> {
----------------
andykaylor wrote:
What I was observing was that the general MLIR folding will only DCE operations that are otherwise modified during the folding process. If I fold something that causes the operation to become unused, the MLIR folding will remove it. However, if it is already unused on input, it does not get automatically removed. Apparently, the general folding is not checking the uses of every operation. However, after typing the previous statement, it occurred to me that just adding `ConstantOp` to the list of operations on which we apply folding greedily would be sufficient. I'll make that change.
https://github.com/llvm/llvm-project/pull/175675
More information about the cfe-commits
mailing list