[clang] [clang] constexpr integer `__builtin_elementwise_{max,min}` (PR #152294)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 22 08:37:11 PDT 2025


================
@@ -13548,7 +13583,24 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
     APInt Result = LHS.isSigned() ? LHS.ssub_sat(RHS) : LHS.usub_sat(RHS);
     return Success(APSInt(Result, !LHS.isSigned()), E);
   }
+  case Builtin::BI__builtin_elementwise_max: {
+    APSInt LHS, RHS;
+    if (!EvaluateInteger(E->getArg(0), LHS, Info) ||
+        !EvaluateInteger(E->getArg(1), RHS, Info))
+      return false;
+
+    APInt Result = std::max(LHS, RHS);
+    return Success(APSInt(Result, !LHS.isSigned()), E);
----------------
shafik wrote:

Ahh ok, so then we should have tests showing that this case is rejected and does not work, do we have those someplace else?

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


More information about the cfe-commits mailing list