Re: Show C's Integer Promotions and Usual Arithmetic Conversions.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/23/19 6:10 PM, Ralph Corderoy wrote:
> Is there a way to get gcc to show C's `integer promotions' and
> `usual arithmetic conversions' that it has applied to an expression?
> Even if it needs a bit of untangling from the main thing it's
> trying to show.  I was wondering if one of the many `-d' developer
> options or `dump' options would show that stage.

It would be very hard. A lot of this stuff is done in the C front end
before it even gets as far as GIMPLE generation. The FE logic doesn't
even record the conversions that have been done, it just applies them.

Having said that, you can see some conversions in -fdump-tree-original
in the cases where the logic in the compiler needs them.

For example,

unsigned mod_m(unsigned n) {
  unsigned tmp = n % 65536l;
  tmp -= n / 65536.0;
  if (tmp >= 65537) // overflow
    tmp += 65537l;
  return tmp;
}

becomes

{
  unsigned int tmp = n & 65535;

    unsigned int tmp = n & 65535;
  tmp = (unsigned int) ((double) tmp - (double) n / 6.5536e+4);
  if (tmp > 65536)
    {
      tmp = tmp + 65537;
    }
  return tmp;
}

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux