------- Comment #1 from jakub at gcc dot gnu dot org  2010-08-24 13:35 -------
On the C FE side, perhaps these optimizations should be moved over from
convert_to_integer to e.g. c_fully_fold_internal, where the operand would be
folded first and only afterwards the narrowing conversion optimization would be
applied.  That would solve this testcase too, but wouldn't help the case where
the narrowing conversion is done by the user already.

int foo (const unsigned char *a, int b, int c)
{
  int x = (unsigned char) (a[b] + c);
  int y = a[b] + c;
  int z = (unsigned char) y;
  return x == z;
}

is another testcase which isn't currently optimized at the tree level (the RTL
level can figure this out though).


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jsm28 at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45397

Reply via email to