On Tue, May 3, 2011 at 12:00 PM, Richard Guenther <richard.guent...@gmail.com> wrote: >>>> 3) it limits the lowering into one form which may not be ideal -- >>>> with builtin_dispatch, after hoisting optimization, the lowering can >>>> use more efficient IFUNC scheme, for instance. >>> >>> I see no reason why we cannot transform a switch-indirect-call >>> pattern into an IFUNC call. >>> >> >> It is possible -- but it is like asking user to lower the dispatch and >> tell compiler to raise it again .. > > There is no possibility for a high-level dispatch at the source level. > And if I'd have to design one I would use function overloading, like > > float compute_sth (float) __attribute__((version("sse4"))) > { > ... sse4 code ... > } > > float compute_sth (float) > { > ... fallback ... > } > > float foo (float f) > { > return compute_sth (f); > } > > and if you not only want to dispatch for target features you could > specify a selector function and value in the attribute. You might > notice that the above eventually matches the target attribute > directly, just the frontends need to be taught to emit dispatch > code whenever overload resolution results in ambiguities involving > target attribute differences.
Which also would allow the frontend to directly call the sse4 variant if you compile with -msse4, avoiding the need for any fancy processing. Richard.