Skip to content

Commit

Permalink
compiler: Don't make temporaries for constant operands.
Browse files Browse the repository at this point in the history
Fixes golang/go#12616.

Change-Id: I07e02744b7af94f5820ddbd3360d33e2573ce49b
Reviewed-on: https://go-review.googlesource.com/14645
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Oct 7, 2015
1 parent 651e71a commit a4bcd31
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go/expressions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5200,13 +5200,13 @@ Binary_expression::do_flatten(Gogo* gogo, Named_object*,
|| (is_idiv_op
&& (gogo->check_divide_by_zero() || gogo->check_divide_overflow())))
{
if (!this->left_->is_variable())
if (!this->left_->is_variable() && !this->left_->is_constant())
{
temp = Statement::make_temporary(NULL, this->left_, loc);
inserter->insert(temp);
this->left_ = Expression::make_temporary_reference(temp, loc);
}
if (!this->right_->is_variable())
if (!this->right_->is_variable() && !this->right_->is_constant())
{
temp =
Statement::make_temporary(NULL, this->right_, loc);
Expand Down

0 comments on commit a4bcd31

Please sign in to comment.