On 11/05/2021 19:00, Joseph Myers wrote: > On Tue, 11 May 2021, David Brown wrote: > >> It is also worth noting that gcc already has support for saturating >> types on some targets: >> >> <https://gcc.gnu.org/onlinedocs/gcc/Fixed-Point.html> >> >> My testing of these (quite a long time ago) left me with a feeling that >> it was not a feature anyone had worked hard to optimise - certainly it > > The implementation isn't well-integrated with any optimizations for > arithmetic on ordinary integer types / modes, because it has its own > completely separate machine modes and operations on those. I still think > it would be better to have a GIMPLE pass that lowers from fixed-point > types to saturating etc. operations on ordinary integer types, as I said > in <https://gcc.gnu.org/legacy-ml/gcc-patches/2011-05/msg00846.html>.
That would make sense (to me anyway, with my limited knowledge), especially if this work on ordinary integer types pays off. That would surely let you simplify the sat/accum/fract type handling while simultaneously making it work on a wider variety of targets. > > Note however that such lowering should be more or less independent of > what's being discussed in this thread - this thread is about better > optimization of such operations on ordinary types (with or without > built-in functions of some kind in addition to recognition of such > operations written in generic C), which you can do independently of > what's done with fixed-point types. > Yes, indeed. I mentioned them for comparison, and in case there were ideas which could be copied. I don't think the N1169/TR 18037 types are much (if ever) used in real code - with Tamar's planned optimisations, the use-cases for them will be even fewer.