Comment 2 for bug 634682

Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

This program has the same problem:

  unsigned char
  f (unsigned int c)
  {
    if (c < 50)
      return c;
    return 0;
  }

Upstream GCC (pre-4.6) with "-mcpu=cortex-a8 -O2" gives:

        cmp r0, #49
        uxtbls r0, r0
        movhi r0, #0
        bx lr

As far as I can see, the only compiler pass that could "know" that the zero-extend is redundant is the VRP pass (Value Range Propagation). It's not totally clear to me whether it's supposed to be able to remove/annotate the type conversion, and it's not working, or whether this is just not addressed anywhere in the compiler.