Tomasz Kaminski [Monday, 20 October 2025, 10:47:12 CEST]:
> […] so what I suggest instead is to introduce:
> 
> template<typename... _Args>
> [[__gnu__::__always_inline__]]
> constexpr __should_constprop(const _Args&... __args)
> {
>    if conteval { // of if (__builtin_is_constant_evaluated())
>      return true;
>   }
>  return __is_constprop(__args) && ...;
> }
> 
> The _M_isconstprop member on simd, should become __is_constprop hidden
> friend.
> […]

BTW, I re-checked why I needed __builtin_is_constant_evaluated() even though 
__builtin_constant_p(arg) should always be true in constant evaluated code. It 
seems this was only necessary for Clang <= 18. I'd still keep it as a shortcut 
in the multi-arg overload to avoid asking all these __is_constprop questions 
in constant expressions.

Also, the difference in naming between __should_constprop and __is_constprop 
is too subtle. I now named both functions __is_constprop. With Clang >= 19 
that should also be fine.

However, I'm not really happy with how the code reads now, because that "is 
constprop" includes is_constant_evaluated isn't that obvious in the name.

How about __is_value_known(...) instead of __is_constprop(...)?

Motivation: e.g.

  if (!__is_constprop(__x))

This is saying "if not consteval and the value of __x is not constant 
propagated". But that first part is not obvious IMHO.

  if (!__is_value_known(__x))

The value clearly is known in a constant expression. Maybe it's less clear 
that the value can also be known via constant propagation. But that shouldn't 
really matter.

- Matthias

-- 
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Center for Heavy Ion Research               https://gsi.de
 std::simd
──────────────────────────────────────────────────────────────────────────

Reply via email to