This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fwd: [RFC PATCH]: Reciprocal sqrt (rsqrt) conversion pass


On 6/13/07, Richard Guenther <richard.guenther@gmail.com> wrote:

> Attached RFC patch implements reciprocal pass that converts sqrt to
> rsqrt. The pass converts several forms of sqrt:
>
> a / sqrt(b / c) => a * rsqrt (c / b)

a * rsqrt (b / c) I suppose.

Yes, of course. Actually "a / sqrt(b) => a * rsqrt (b)".


> sqrt (a / b) => rsqrt ( b / a)

this could be done in sqrt builtin expansion instead?  (Of course we may not see
the a / b argument there)

Because of a/b -> b/a transformation. During expansion, we see only a register, and we can't just split. However, the most important reason is, that by throwing a reciprocal (1.0/x) in the mix, we already expanded (a / b) into NR-enhanced a*rcp(b). There is no RTL pass that could combine everyting back to something resembling the transformation above.

> sqrt (a) => a * rsqrt (a)


Likewise.

Coud be. But since we need the transformation above, it is just a few lines for the above functionality.

All of the transformations need to be guarded with
flag_unsafe_math_optimizations.

On tree level, they are (target stuff is there just for example, it is still in the development).

I bet if you change

def_builtin (OPTION_MASK_ISA_SSE, "__builtin_ia32_rsqrtf", ftype,
IX86_BUILTIN_RSQRTF);

to use def_builtin_const it will work.

;)) Thanks, this was it.


Thanks,
Uros.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]