On Sat, Nov 28, 2015 at 09:38:40AM +0100, Jakub Jelinek wrote:
> On Sat, Nov 28, 2015 at 08:47:18AM +0100, Richard Biener wrote:
> > On November 27, 2015 8:40:56 PM GMT+01:00, Jakub Jelinek <ja...@redhat.com> 
> > wrote:
> > >The recent changes where vector sqrt is represented in the IL using
> > >IFN_SQRT instead of target specific builtins broke the discovery
> > >of vector rsqrt, as targetm.builtin_reciprocal is called only
> > >on builtin functions (not internal functions).  Furthermore,
> > >for internal fns, not only the IFN_* is significant, but also the
> > >types (modes actually) of the lhs and/or arguments.
> > >
> > >This patch adjusts the target hook, so that the backends can just
> > >inspect
> > >the call (builtin or internal function), whatever it is.
> > >
> > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > 
> > OK.  Though the other option would be to add an optab with corresponding 
> > IFN.
> 
> Yeah, I've been thinking about IFN_RSQRT and rsqrt optab, perhaps that is
> cleaner and the target hook could go away completely.

So, had a look at this, and the only issue I see is that the various
targetm.builtin_reciprocal implementations start with various fancy
conditions:
  if (! (TARGET_SSE_MATH && !optimize_insn_for_size_p ()
         && flag_finite_math_only && !flag_trapping_math
         && flag_unsafe_math_optimizations))
    return NULL_TREE;
on i?86,
  if (optimize_insn_for_size_p ())
    return NULL_TREE;
on rs6000 and
  if (flag_trapping_math
      || !flag_unsafe_math_optimizations
      || optimize_size
      || ! (aarch64_tune_params.extra_tuning_flags
           & AARCH64_EXTRA_TUNE_RECIP_SQRT))
on aarch64.  The recip pass is only guarded by its gate, which doesn't say
anything from the above.
So, shall I move these conditions to the rsqrt<sf,v4sf,v8sf,v2df>2 expanders
(but not sure if e.g. the tuning flags or !optimize_size or
!optimize_insn_for_size_p () is appropriate for expander conditions), keep
the builtin_reciprocal hook (perhaps renamed to builtin_rsqrt) for the
purpose of this condition and nothing else (i.e. return a boolean) and let
the rest be determined from the optab, just commit the already posted patch,
something else?

        Jakub

Reply via email to