On Tue, Jul 08, 2025 at 11:54:23PM -0600, Alex (Waffl3x) wrote:
> --- a/gcc/tree.h
> +++ b/gcc/tree.h
> @@ -571,6 +571,15 @@ extern void omp_clause_range_check_failed (const_tree, 
> const char *, int,
>    TREE_CHECK6 (T, INTEGER_TYPE, ENUMERAL_TYPE, BOOLEAN_TYPE, REAL_TYPE,      
> \
>              FIXED_POINT_TYPE, BITINT_TYPE)
>  
> +/* Check if the bits field of tree_base is available for NODE.
> +   Note, CALL_EXPR also sometimes makes use of the ifn union member, it would
> +   be invalid to use TREE_LANG_FLAG_* when this is the case but it can't be
> +   checked for here.  */
> +#define TREE_CHECK_BITS_AVAILABLE(NODE) \
> +  ((TREE_NOT_CHECK7 (NODE, INTEGER_CST, TREE_VEC, VECTOR_CST, SSA_NAME, \
> +                  POLYNOMIAL_CHREC, MEM_REF, TARGET_MEM_REF), void ()), \
> +   TREE_NOT_RANGE_CHECK (NODE, OMP_ATOMIC, OMP_ATOMIC_CAPTURE_NEW))

This evaluates NODE twice rather than once.  I'm quite sure there will be
some uses of the many macros with side-effects in the arguments.
Can't you TREE_NOT_RANGE_CHECK in the first argument of TREE_NOT_CHECK7?

Also, have you looked at how code size grew with these patches and compile
time changed?  Whether the checking doesn't become way too expensive...
E.g. if it wouldn't be better to have a bool array indexed by TREE_CODE
for TREE_CHECK_BITS_AVAILABLE, initialized somewhere.  With C++14 could be
even constexpr.

        Jakub

Reply via email to