On Tue, Jul 21, 2026 at 02:20:51PM +0200, Jakub Jelinek via Gcc wrote:
> On Tue, Jul 21, 2026 at 12:06:06PM +0200, Arsen Arsenović wrote:
> > It is an improvement. The former detects errors at runtime, meaning
>
> It is not an improvement, it is extra pain.
To expand on this, if some particular tree or GIMPLE or RTL is used in
large amounts of code and all that code needs to know what exact
kind of tree, GIMPLE or RTL it is, then static typing perhaps can bring
some theoretical advantages.
But that isn't how most of the GCC codebase looks like.
We have the IL (whether GENERIC, GIMPLE or RTL), we traverse it,
detect whatever we are looking for and depending on TREE_CODE, gimple_code,
GET_CODE perform some action on it.
Now, if the usual case is that you have 10 different calls on a particular
type, then again, static typing after a dyn_cast could in theory help.
But that is not the usual case. Usually there is just one call specific to
the particular code, or two. And in that case the dyn_casts that have to
be sprinkled around don't bring any advantages, just make the code harder to
read, bring indentation issues etc.
Jakub