Hi all,

Consider code:
long int
foo (double a)
{
   return __builtin_round (a);
}

Compiling for aarch64-none-elf (bare-metal aarch64 with newlib as C-library) with -O2 gives the 003t.original dump:

;; Function foo (null)
;; enabled by -tree-original


{
  return (long int) __builtin_round (a);
}


whereas compiling for aarch64-none-linux-gnu (linux target with glibc) gets translated into:

;; Function foo (null)
;; enabled by -tree-original


{
  return __builtin_lround (a);
}

These end up taking different codepaths through the compiler () because __builtin_lround has to take -fmath-errno into account and does not end up getting inlined (generating a call to the library lround).

__builtin_round, however, is defined everywhere and ends up getting expanded to a

rounddf optab + (set r:DI (fix:DI (r:DF)))

which then later gets combined into the expansion we've got for the lrounddfdi2 optab

Is that correct/expected behaviour?
I tried grepping around the gcc sources but I'm not familiar with code that would do the frontend transformation mentioned above.

Thanks,
Kyrill

Reply via email to