PipelineC icon indicating copy to clipboard operation
PipelineC copied to clipboard

Resource sharing, implement optimization pass

Open JulianKemmerer opened this issue 2 years ago • 0 comments

Want to detect and fix things like for ex. below where the same functionality can be done with '1 multiplier and more muxing' instead of '2 multipliers and fewer muxing'.

2 multipliers and fewer muxing

int32_t two_multipliers(uint1_t sel, int32_t a, int32_t b)
{
  int32_t rv;
  if(sel)
  {
    rv = a * a;
  }
  else
  {
    rv = b * b;
  }
  return rv;
}

1 multiplier and more muxing

int32_t one_multiplier(uint1_t sel, int32_t a, int32_t b)
{
  int32_t rv;
  int32_t mult_left;
  int32_t mult_right;
  if(sel)
  {
    mult_left = a;
    mult_right = a;
  }
  else
  {
    mult_left = b;
    mult_right = b;
  }
  rv = mult_left * mult_right;
  return rv;
}

JulianKemmerer avatar May 29 '22 03:05 JulianKemmerer