This is the mail archive of the gcc-patches@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: [PATCH] Fix PR53501


On Fri, 1 Jun 2012, Eric Botcazou wrote:

> > Ah, I see.  So the proper fix would be to use STRIP_NOP()ed op0/op1,
> > something not readily available though.
> 
> Why not just add
> 
>   TYPE_UNSIGNED (TREE_TYPE (op0)) == TYPE_UNSIGNED (TREE_TYPE (arg0))
>   && TYPE_UNSIGNED (TREE_TYPE (op1)) == TYPE_UNSIGNED (TREE_TYPE (arg1))
> 
> with a small comment?

Well, it would rather be

  TYPE_UNSIGNED (type) == TYPE_UNSIGNED (TREE_TYPE (arg0))
  && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (TREE_TYPE (arg1))

but only in the !FLOAT_TYPE_P path.  We could even compare
TYPE_OVERFLOW_UNDEFINED I think.  Or even just make sure
that when TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg0)) also
TYPE_OVERFLOW_UNDEFINED (type), thus

  !TYPE_OVERFLOW_UNDEFINED (type)
  || ((TREE_CODE (arg0) != MULT_EXPR
       || TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg0)))
      && (TREE_CODE (arg1) != MULT_EXPR
          || TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1))))

That is, the newly created multiplication in type TYPE should
either not have undefined overflow or the inner multiplications
all should already have.  Best done with a comment in
fold_plusminus_mult_expr.

Richard.


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