On 10/28/26 6:48 AM, Jakub Jelinek wrote:
--- a/gcc/cp/constexpr.cc       2026-10-23 15:12:24.052873710 +0200
+++ b/gcc/cp/constexpr.cc       2026-10-27 08:41:24.586219933 +0100
@@ -3723,6 +3723,54 @@ cxx_eval_internal_function (const conste
                                                      arg);
        }
+ case IFN_CLMUL:
+      {
+       tree args[3] = {};
+       for (int i = 0; i < call_expr_nargs (t); ++i)
+         {
+           args[i] = cxx_eval_constant_expression (ctx, CALL_EXPR_ARG (t, i),
+                                                   vc_prvalue, non_constant_p,
+                                                   overflow_p, jump_target);
+           if (*jump_target)
+             return NULL_TREE;
+           if (*non_constant_p)
+             return t;
+         }
+       location_t loc = cp_expr_loc_or_input_loc (t);
+       if (TREE_CODE (args[0]) != INTEGER_CST
+           || TREE_CODE (args[1]) != INTEGER_CST
+           || !INTEGRAL_TYPE_P (TREE_TYPE (args[0]))
+           || !TYPE_UNSIGNED (TREE_TYPE (args[0]))
+           || !same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (args[0])),
+                            TYPE_MAIN_VARIANT (TREE_TYPE (args[1])))
+           || (args[2] && !POINTER_TYPE_P (TREE_TYPE (args[2]))))

Aren't the types checked when building the expression in the first place?

+         {
+           if (!ctx->quiet)
+             error_at (loc, "call to internal function %qE", t);
+           *non_constant_p = true;
+           return t;
+         }
+       unsigned int prec = TYPE_PRECISION (TREE_TYPE (args[0]));
+       wide_int res = wi::clmul (wi::to_wide (args[0]),
+                                 wi::to_wide (args[1]),
+                                 prec * (args[2] ? 2 : 1));
+       if (args[2] == NULL_TREE)
+         return wide_int_to_tree (TREE_TYPE (t), res);
+       wide_int lo = wide_int::from (res, prec, UNSIGNED);
+       wide_int hi = wide_int::from (wi::rshift (res, prec, UNSIGNED),
+                                     prec, UNSIGNED);
+       tree mod = build2_loc (loc, MODIFY_EXPR, void_type_node,
+                              build_fold_addr_expr_loc (loc, args[2]),

Shouldn't this be build_fold_indirect_ref_loc?

It looks like there are no constexpr tests?

Jason

Reply via email to