This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Confused about code/comment in tree.c:build2


On Fri, 31 Jan 2020, Bin.Cheng wrote:

> Hi,
> In tree.c:build2 there is following code/comment:
> 
>   if ((code == MINUS_EXPR || code == PLUS_EXPR || code == MULT_EXPR)
>       && arg0 && arg1 && tt && POINTER_TYPE_P (tt)
>       /* When sizetype precision doesn't match that of pointers
>          we need to be able to build explicit extensions or truncations
>          of the offset argument.  */
>       && TYPE_PRECISION (sizetype) == TYPE_PRECISION (tt))
>     gcc_assert (TREE_CODE (arg0) == INTEGER_CST
>                 && TREE_CODE (arg1) == INTEGER_CST);
> 
> The comment says specific condition needs to be satisfied if sizetype
> precision doesn't match that of pointers, while the code is checking
> "==" of precisions?  Any explanation?

On targets where sizetype mode != ptr_mode the assert fires for reasons
I do not remember.  The comment is a bit confusing since we're
dealing with plus/minus/mult here, not truncations or extensions
also the assert will still allow to-be-constant-folded values
(guess fold-const.c doesn't honor the restrictions).

In reality minus/plus/mult should never be used on pointers.

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]