[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed May 28 10:58:40 PDT 2025


================
@@ -306,6 +306,24 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
     return createBinop(loc, lhs, cir::BinOpKind::Or, rhs);
   }
 
+  mlir::Value createSelect(mlir::Location loc, mlir::Value condition,
+                           mlir::Value trueValue, mlir::Value falseValue) {
+    assert(trueValue.getType() == falseValue.getType() &&
+           "trueValue and falseValue should have the same type");
+    return create<cir::SelectOp>(loc, trueValue.getType(), condition, trueValue,
+                                 falseValue);
+  }
+
+  mlir::Value createLogicalAnd(mlir::Location loc, mlir::Value lhs,
----------------
andykaylor wrote:

It appears these will only work if lhs and rhs are bool values. I guess the assert above will force that, but it initially surprised me.

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


More information about the cfe-commits mailing list