[clang] [CIR] Fold unary operations and simple casts (PR #174670)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 7 12:25:11 PST 2026


================
@@ -781,9 +841,26 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
     return result;
   }
 
+  mlir::Value foldUnaryOp(const UnaryOperator *e) {
+    Expr::EvalResult result;
+    if (!e->EvaluateAsRValue(result, cgf.getContext()))
----------------
andykaylor wrote:

With the folding approach, I'm going to break this up into several pieces, implementing the folding as a canonicalization first and then inserting `createOrFold` calls as a follow-up. The first PR is https://github.com/llvm/llvm-project/pull/174861.

https://github.com/llvm/llvm-project/pull/174670


More information about the cfe-commits mailing list