[match.pd] PR83750 - CSE erf/erfc pair
Richard Biener
rguenther@suse.de
Mon Oct 18 10:48:54 GMT 2021
On Mon, 18 Oct 2021, Prathamesh Kulkarni wrote:
> Hi Richard,
> As suggested in PR, I have attached WIP patch that adds two patterns
> to match.pd:
> erfc(x) --> 1 - erf(x) if canonicalize_math_p() and,
> 1 - erf(x) --> erfc(x) if !canonicalize_math_p().
>
> This works to remove call to erfc for the following test:
> double f(double x)
> {
> double g(double, double);
>
> double t1 = __builtin_erf (x);
> double t2 = __builtin_erfc (x);
> return g(t1, t2);
> }
>
> with .optimized dump shows:
> t1_2 = __builtin_erf (x_1(D));
> t2_3 = 1.0e+0 - t1_2;
>
> However, for the following test:
> double f(double x)
> {
> double g(double, double);
>
> double t1 = __builtin_erfc (x);
> return t1;
> }
>
> It canonicalizes erfc(x) to 1 - erf(x), but does not transform 1 -
> erf(x) to erfc(x) again
> post canonicalization.
> -fdump-tree-folding shows that 1 - erf(x) --> erfc(x) gets applied,
> but then it tries to
> resimplify erfc(x), which fails post canonicalization. So we end up
> with erfc(x) transformed to
> 1 - erf(x) in .optimized dump, which I suppose isn't ideal.
> Could you suggest how to proceed ?
I applied your patch manually and it does the intended
simplifications so I wonder what I am missing?
Richard.
> Thanks,
> Prathamesh
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)
More information about the Gcc-patches
mailing list