[Mlir-commits] [mlir] [mlir][emitc] Mark emitc.literal with CExpression (PR #155582)

Simon Camphausen llvmlistbot at llvm.org
Wed Aug 27 04:29:09 PDT 2025


================
@@ -439,3 +439,29 @@ emitc.func @expression_with_call_opaque_with_args_array(%0 : i32, %1 : i32) {
   }
   return
 }
+
+
+// CPP-DEFAULT:      bool expression_with_literal(int32_t [[VAL_1:v[0-9]+]]) {
+// CPP-DEFAULT-NEXT:   bool [[VAL_2:v[0-9]+]] = (1 + [[VAL_1]]) / 2 < 3;
+// CPP-DEFAULT-NEXT:   return [[VAL_2]];
+// CPP-DEFAULT-NEXT: }
+
+// CPP-DECLTOP:      bool expression_with_literal(int32_t [[VAL_1:v[0-9]+]]) {
+// CPP-DECLTOP-NEXT:   bool [[VAL_2:v[0-9]+]];
+// CPP-DECLTOP-NEXT:   [[VAL_2]] = (1 + [[VAL_1]]) / 2 < 3;
+// CPP-DECLTOP-NEXT:   return [[VAL_2]];
+// CPP-DECLTOP-NEXT: }
+
+func.func @expression_with_literal(%arg0 : i32) -> i1 {
+  %ret = emitc.expression noinline : i1 {
----------------
simon-camp wrote:

Literals are Always inlined. Can we have a Test that wraps a single literal and that gets inlined into it's use?
Like `return(expression(literal(...)))`

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


More information about the Mlir-commits mailing list