[RFC] Saturating using arithmetic in address calculation.
Joseph S. Myers
joseph@codesourcery.com
Sat Oct 26 21:26:00 GMT 2013
On Sat, 26 Oct 2013, Ondrej Bilka wrote:
> For that performance a assembly version/gcc builtin would be needed. A
> portable implementation would have comparable performance with manual
> checks.
For saturating multiplication in size_t where one argument is a constant,
I don't think much optimization arises. There may be other cases where
such optimizations would be more significant.
I don't think C does a good job of providing fine control of overflow
handling of integer operations, such as saturating arithmetic, although
there are various purposes for which you'd like to do such an operation
explicitly and let the compiler work out how best to optimize it for a
given system, rather than writing more complicated C code and hoping that
the compiler can recognize your idiom (see
<http://saluc.engr.uconn.edu/refs/compiler/bik02idioms.pdf> for how some
idioms might be recognized). In particular, I think the TR 18037
(embedded C) approach of saturating fixed-point types with a keyword _Sat
is poorly matched to the uses of saturation in typical C code (it may be
of more use to the target DSP audience of that TR) - and that the
implementation approach for that TR in GCC, using a large number of new
machine modes rather than lowering to operations on generic types and
modes, is also problematic.
However, that TR 18037 approach is what there's so far been interest in
standardizing, or in implementing in GCC, rather than any approach for
operations with explicit overflow handling such as discussed in GCC PR
48580.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list