Am Sonntag, dem 14.12.2025 um 15:10 +0100 schrieb Andreas Schwab:
> On Dez 14 2025, Martin Uecker via Gcc wrote:
> 
> > One could use templates in C++ or macros, but then this is
> > rather heavy weight and also rigid as one has to structure the
> > code around it.   I am rather looking for some lightweight 
> > solution such as annotation I could put on the argument or variable
> > that says: If this is value is known to be a compile-time
> > constant, please create a specialized code path when optimizing.
> > (maybe with some limit on recursion), maybe only for specified
> > parameter ranges.
> > 
> > Or are there other better ways to do this already?
> 
> Is __builtin_constant_p what you are looking for?

Not really.  I know I can use it in some inline wrapper to
add my own compile-time specialization, but I want the compiler
to create the specialized code for me without having to duplicate
it the source.  It can specialize code already just fine if it 
likes to do so, but there seems to be no good  way to 
enforce this.

Martin

Reply via email to