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

via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 14 03:14:45 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- clang/lib/AST/ByteCode/InterpBuiltin.cpp clang/lib/AST/ExprConstant.cpp clang/test/Sema/constant-builtins-vector.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 5375b184b..cb5c981c0 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2396,7 +2396,7 @@ static bool interp__builtin_elementwise_maxmin(InterpState &S, CodePtr OpPC,
         LHSInt = LHS.elem<T>(I).toAPSInt();
         RHSInt = RHS.elem<T>(I).toAPSInt();
       });
-      
+
       APSInt Result;
       if (BuiltinID == Builtin::BI__builtin_elementwise_max) {
         Result = std::max(LHSInt, RHSInt);
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index b232cd4a7..6eb1fec44 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11710,12 +11710,14 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
         APSInt RHS = SourceRHS.getVectorElt(EltNum).getInt();
         switch (E->getBuiltinCallee()) {
         case Builtin::BI__builtin_elementwise_max:
-          ResultElt = APValue(APSInt(std::max(LHS, RHS),
-                                      DestEltTy->isUnsignedIntegerOrEnumerationType()));
+          ResultElt =
+              APValue(APSInt(std::max(LHS, RHS),
+                             DestEltTy->isUnsignedIntegerOrEnumerationType()));
           break;
         case Builtin::BI__builtin_elementwise_min:
-          ResultElt = APValue(APSInt(std::min(LHS, RHS),
-                                      DestEltTy->isUnsignedIntegerOrEnumerationType()));
+          ResultElt =
+              APValue(APSInt(std::min(LHS, RHS),
+                             DestEltTy->isUnsignedIntegerOrEnumerationType()));
           break;
         }
       } else if (DestEltTy->isRealFloatingType()) {
@@ -15929,7 +15931,7 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__builtin_fmaxf:
   case Builtin::BI__builtin_fmaxl:
   case Builtin::BI__builtin_fmaxf16:
-  case Builtin::BI__builtin_fmaxf128: 
+  case Builtin::BI__builtin_fmaxf128:
   case Builtin::BI__builtin_elementwise_max: {
     APFloat RHS(0.);
     if (!EvaluateFloat(E->getArg(0), Result, Info) ||

``````````

</details>


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


More information about the cfe-commits mailing list