take type from intrinsic in sincos pass
authorAlexandre Oliva <oliva@adacore.com>
Thu, 8 Oct 2020 20:12:18 +0000 (17:12 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Thu, 8 Oct 2020 20:12:18 +0000 (17:12 -0300)
commita500588aa523f1f04ae51809e476e3ebfcb081d3
tree15e5f671a4efdb0fe4f0dd74cd0a87b1c84b165b
parentd1c566d72d9361b37213881222c7e2713cdf05b7
take type from intrinsic in sincos pass

This is a first step towards enabling the sincos optimization in Ada.

The issue this patch solves is that sincos takes the type to be looked
up with mathfn_built_in from variables or temporaries passed as
arguments to SIN and COS intrinsics.  In Ada, different float types
may be used but, despite their representation equivalence, their
distinctness causes the optimization to be skipped, because they are
not the types that mathfn_built_in expects.

This patch introduces a function that maps intrinsics to the type
they're associated with, and uses that type, obtained from the
intrinsics used in calls to be optimized, to look up the correspoding
CEXPI intrinsic.

For the sake of defensive programming, when using the type obtained
from the intrinsic, it now checks that, if different types are found
for the used argument, or for other calls that use it, that the types
are interchangeable.

for  gcc/ChangeLog

* builtins.c (mathfn_built_in_type): New.
* builtins.h (mathfn_built_in_type): Declare.
* tree-ssa-math-opts.c (execute_cse_sincos_1): Use it to
obtain the type expected by the intrinsic.
gcc/builtins.c
gcc/builtins.h
gcc/tree-ssa-math-opts.c