[PATCH] Add pass to CSE sin (x) and cos (x) to sincos (x)

Uros Bizjak ubizjak@gmail.com
Fri Jan 19 14:54:00 GMT 2007


Hello Richard!

> This is the revised patch I am going to commit after a few days of
> no further objection.

> 2006-12-27  Richard Guenther  <rguenther@suse.de>

> 	PR tree-optimization/30028
>	* tree-ssa-math-opts.c (maybe_record_sincos): New static helper
>	function.
>	(execute_cse_sincos_1): Likewise.

For some reason your patch misses transformation for the testcase below:

--cut here--
typedef struct cmplx { double x,y; } CMPLX;

void Complex_Sin (CMPLX *target, CMPLX *source)
{
  target->x = sin(source->x) * cosh(source->y);
  target->y = cos(source->x) * sinh(source->y);
} /* End Complex_Sin() */
--cut here--

.sincos tree dump says:

Complex_Sin (target, source)
{
  double D.1627;
  double D.1626;
  double D.1625;
  double D.1624;
  double D.1623;
  double D.1622;
  double D.1621;
  double D.1620;

<bb 2>:
  D.1620_2 = source_1(D)->x;
  D.1621_3 = sin (D.1620_2);
  D.1622_4 = source_1(D)->y;
  D.1623_5 = cosh (D.1622_4);
  D.1624_6 = D.1621_3 * D.1623_5;
  target_7(D)->x = D.1624_6;
  D.1620_8 = source_1(D)->x;
  D.1625_9 = cos (D.1620_8);
  D.1622_10 = source_1(D)->y;
  D.1626_11 = sinh (D.1622_10);
  D.1627_12 = D.1625_9 * D.1626_11;
  target_7(D)->y = D.1627_12;
  return;

}

Uros.



More information about the Gcc-patches mailing list