[clang] [CIR] Add support for ldexp builtins (PR #236997)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 14:05:39 PST 2026


================
@@ -8761,6 +8761,42 @@ def CIR_ATan2Op : CIR_BinaryFPToFPBuiltinOp<"atan2", "ATan2Op"> {
   let constrainedLLVMIntrinsic = "atan2";
 }
 
+def CIR_LdexpOp : CIR_Op<"ldexp",
+    !listconcat([AllTypesMatch<["src", "result"]>], CIR_FenvOpTraits)> {
+  let summary = "Multiplies a floating-point value by an integral power of two";
+  let description = [{
+    `cir.ldexp` computes `src * 2^exp`.
+
+    Lowers to `llvm.ldexp`, or to `llvm.experimental.constrained.ldexp` when
+    the `fenv` attribute is present.
+
+    Example:
+      %r = cir.ldexp %x, %e : !cir.float, !s32i
+  }];
+
+  let arguments = (ins
+    CIR_AnyFloatType:$src,
----------------
andykaylor wrote:

The corresponding LLVM operation allows a vector of floats, though it doesn't appear to handle a vector of integers for the power, which is what we'd expect with something like this:

`  vf2 = __builtin_elementwise_ldexp(vf1, vi1);`

>From (clang/test/CodeGen/builtins-elementwise-math.c)

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


More information about the cfe-commits mailing list