This is the mail archive of the gcc-bugs@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]

[Bug middle-end/81814] [5/6/7/8 Regression] Incorrect behaviour at -O0 (conditional operator)


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81814

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |middle-end
   Target Milestone|---                         |5.5
            Summary|Incorrect behaviour at -O0  |[5/6/7/8 Regression]
                   |(conditional operator)      |Incorrect behaviour at -O0
                   |                            |(conditional operator)

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #8)
> I wonder if I could just
> 
> --- a/gcc/fold-const.c
> +++ b/gcc/fold-const.c
> @@ -3401,14 +3401,14 @@ operand_equal_for_comparison_p (tree arg0, tree
> arg1, tree other)
>  
>    primarg1 = get_narrower (arg1, &unsignedp1);
>    primother = get_narrower (other, &unsignedpo);
> +  tree type = TREE_TYPE (arg0);
>  
>    correct_width = TYPE_PRECISION (TREE_TYPE (arg1));
>    if (unsignedp1 == unsignedpo
> +      && TYPE_PRECISION (TREE_TYPE (primarg1)) == TYPE_PRECISION (type)
>        && TYPE_PRECISION (TREE_TYPE (primarg1)) < correct_width
>        && TYPE_PRECISION (TREE_TYPE (primother)) < correct_width)
>      {
> -      tree type = TREE_TYPE (arg0);
> -
>        /* Make sure shorter operand is extended the right way
>      to match the longer operand.  */
>        primarg1 = fold_convert (signed_or_unsigned_type_for
> 
> so far it seems to work.

Looks a bit too conservative to me, without explanation what exactly goes wrong
here.  The code might be confused where it does the extension.

Are there any testcases that break when we change operand_equal_for_comparison
to just do operand_equal_p?

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