Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid storing simple expressions like -x in temporaries #89

Closed
efremale opened this issue Aug 20, 2018 · 1 comment
Closed

Avoid storing simple expressions like -x in temporaries #89

efremale opened this issue Aug 20, 2018 · 1 comment

Comments

@efremale
Copy link
Contributor

Example:

double f(double x) {
  double t = 2 * (-x);
  return t;
}

->

double f_darg0(double x) {
    double _t0 = -x;
    double _d_t = 0 * _t0 + 2 * -1.;
    double t = 2 * _t0;
    return _d_t;
}

In this case, double _t0 = -x seems useless so it makes sense to add such simple unary operators to a list of cases for which temporaries are not generated (now it is literals and references). On the other hand, results of unary operators like ++x must be stored to avoid repeated increment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant