https://gcc.gnu.org/bugzilla/show_bug.cgi?id=22326

--- Comment #13 from luoxhu at gcc dot gnu.org ---
Tried implementation with backprop, found that this model seems not suitable
for double promotion remove with BACK propagation.   i.e:

1) mad1.c

float foo (float x, float y, float z)
{
   return ( y * fabs (x) + z ); 
}

mad1.c.098t.cunrolli:

foo (float x, float y, float z)
{
  double _1;
  float _2;
  double _3;
  double _4;
  double _5;
  double _6;
  float _10;

  <bb 2> [local count: 1073741824]:
  _1 = (double) y_7(D);
  _2 = ABS_EXPR <x_8(D)>;
  _3 = (double) _2;
  _4 = _1 * _3;
  _5 = (double) z_9(D);
  _6 = _4 + _5;
  _10 = (float) _6;
  return _10;
}

mad1.c.099t.backprop:

[USE] _10 in return _10;
[USE] _6 in _10 = (float) _6;
  _6: convert from float to double not important
[DEF] Recording new information for _6 = _4 + _5;
  _6: convert from float to double not important
[USE] _5 in _6 = _4 + _5;
  _5: convert from float to double not important
[DEF] Recording new information for _5 = (double) z_9(D);
  _5: convert from float to double not important
[USE] _4 in _6 = _4 + _5;
  _4: convert from float to double not important
[DEF] Recording new information for _4 = _1 * _3;
  _4: convert from float to double not important
[USE] _3 in _4 = _1 * _3;
  _3: convert from float to double not important
[DEF] Recording new information for _3 = (double) _2;
  _3: convert from float to double not important
[USE] _2 in _3 = (double) _2;
  _2: convert from float to double not important
[DEF] Recording new information for _2 = ABS_EXPR <x_8(D)>;
  _2: convert from float to double not important
[USE] _1 in _4 = _1 * _3;
  _1: convert from float to double not important
[DEF] Recording new information for _1 = (double) y_7(D);
  _1: convert from float to double not important

gimple_simplified to _10 = _13;
Deleting _6 = z_9(D) + _12;
Deleting _5 = (double) z_9(D);
Deleting _4 = _2 * y_7(D);
Deleting _3 = (double) _2;
Deleting _1 = (double) y_7(D);


__attribute__((noinline))
foo (float x, float y, float z)
{
  float _2;
  float _10;
  float _12;
  float _13;

  <bb 2> [local count: 1073741824]:
  _2 = ABS_EXPR <x_8(D)>;
  _12 = _2 * y_7(D);
  _13 = z_9(D) + _12;
  _10 = _13;
  return _10;

}


All convert and promotions could be removed. But if change float x to double x,
it doesn't work now:

2)  mad2.c

float foo (double x, float y, float z)
{
   return ( y * fabs (x) + z ); 
}


mad2.c.098t.cunrolli:

foo (double x, float y, float z)
{
  double _1;
  double _2;
  double _3;
  double _4;
  double _5;
  float _9;

  <bb 2> [local count: 1073741824]:
  _1 = (double) y_6(D);
  _2 = ABS_EXPR <x_7(D)>;
  _3 = _1 * _2;
  _4 = (double) z_8(D);
  _5 = _3 + _4;
  _9 = (float) _5;
  return _9;

}

mad2.c.099t.backprop:

[USE] _9 in return _9;
[USE] _5 in _9 = (float) _5;
  _5: convert from float to double not important
[DEF] Recording new information for _5 = _3 + _4;
  _5: convert from float to double not important
[USE] _4 in _5 = _3 + _4;
  _4: convert from float to double not important
[DEF] Recording new information for _4 = (double) z_8(D);
  _4: convert from float to double not important
[USE] _3 in _5 = _3 + _4;
  _3: convert from float to double not important
[DEF] Recording new information for _3 = _1 * _2;
  _3: convert from float to double not important
[USE] _2 in _3 = _1 * _2;
  _2: convert from float to double not important
[DEF] Recording new information for _2 = ABS_EXPR <x_7(D)>;
  _2: convert from float to double not important
[USE] _1 in _3 = _1 * _2;
  _1: convert from float to double not important
[DEF] Recording new information for _1 = (double) y_6(D);
  _1: convert from float to double not important

Deleting _4 = (double) z_8(D);
Deleting _1 = (double) y_6(D);


EMERGENCY DUMP:

__attribute__((noinline))
foo (double x, float y, float z)
{
  double _2;
  double _3;
  double _5;
  float _9;

  <bb 2> [local count: 1073741824]:
  _2 = ABS_EXPR <x_7(D)>;
  _3 = _2 * y_6(D);
  _5 = _3 + z_8(D);
  _9 = (float) _5;
  return _9;

}

Reply via email to