Add rules to strip away unneeded type casts in expressions
authorTamar Christina <tamar.christina@arm.com>
Fri, 26 Jul 2019 13:05:39 +0000 (13:05 +0000)
committerTamar Christina <tnfchris@gcc.gnu.org>
Fri, 26 Jul 2019 13:05:39 +0000 (13:05 +0000)
commit8f5331b25250d488910f62120f6b268486e99fbf
tree6eef823e90e1830504cf32902e0eb32fca94bda2
parent4517b378af6b412e053e8927972434d8580162d0
Add rules to strip away unneeded type casts in expressions

This patch moves part of the type conversion code from convert.c to match.pd
because match.pd is able to apply these transformations in the presence of
intermediate temporary variables.

Concretely it makes both these cases behave the same

  float e = (float)a * (float)b;
  *c = (_Float16)e;

and

  *c = (_Float16)((float)a * (float)b);

gcc/ChangeLog:

* convert.c (convert_to_real_1): Move part of conversion code...
* match.pd: ...To here.

gcc/testsuite/ChangeLog:

* gcc.dg/type-convert-var.c: New test.

From-SVN: r273826
gcc/ChangeLog
gcc/convert.c
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/type-convert-var.c [new file with mode: 0644]