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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pan2.li at intel dot com

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> (In reply to Andrew Pinski from comment #2)
> > I am 80% sure it was r16-3890-gd0526e8ef0d92e which caused this.
> 
> Yes now I am 99% sure. It looks like it missed the unsigned change between
> the casts.

That is:
```
      if (is_gimple_assign (def)
          && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def)))
        {
          tree cast_rhs = gimple_assign_rhs1 (def);
          unsigned rhs_prec = TYPE_PRECISION (TREE_TYPE (cast_rhs));
          unsigned type_prec = TYPE_PRECISION (type);
          unsigned val_prec = TYPE_PRECISION (TREE_TYPE (val));

          if (type_prec >= rhs_prec && val_prec >= rhs_prec)
            rhs = cast_rhs;
        }
    }
```

Does not check TREE_UNSIGNED between the different casts.
_3 is `unsigned short`
  _4 = (short int) _3;
  _15 = (signed int) _4;

is different from:
_15 = (signed int) _3;

because the first case sign extends from 16bit to 32bit while the second one
zero extends from 16bit.

Reply via email to