This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Partial fix for PR 18048
Hello,
> > 3) A small improvement in number_of_iterations_cond.
> > build_int_cst (type, -1) is not suitable for producing unsigned
> > constant with all bits one, since the bits outside of the precision
> > of the type are set to 1 as well, which makes fold to fail to
> > perform some of the optimizations with such constants.
> ...
>
> > ! bound = EXEC_UNARY (BIT_NOT_EXPR, niter_type,
> > ! build_int_cst_type (niter_type, 0));
> > ! bound = EXEC_BINARY (RSHIFT_EXPR, niter_type, bound, bits);
>
> While this is a good conceptual change, this is not the appropriate
> way to do it. You are creating trees just to get fold() to do
> arithmetic for you, which wastes memory,
no, I am not. 0 is a shared constant, so no allocation for
build_int_cst_type (niter_type, 0)), and EXEC_UNARY is
nondestructive_fold_unary_to_constant that also does not build
any trees (except for the result, of course).
> and you risk having overflow bits set on the constants, which will
> also inhibit optimization.
Evaluation of BIT_NOT_EXPR should not set any overflow bits (if it does,
it should be fixed).
Zdenek