Skip to content

Commit a4bcd31

Browse files
Chris Manghaneianlancetaylor
Chris Manghane
authored andcommitted
compiler: Don't make temporaries for constant operands.
Fixes golang/go#12616. Change-Id: I07e02744b7af94f5820ddbd3360d33e2573ce49b Reviewed-on: https://go-review.googlesource.com/14645 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 651e71a commit a4bcd31

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

go/expressions.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -5200,13 +5200,13 @@ Binary_expression::do_flatten(Gogo* gogo, Named_object*,
52005200
|| (is_idiv_op
52015201
&& (gogo->check_divide_by_zero() || gogo->check_divide_overflow())))
52025202
{
5203-
if (!this->left_->is_variable())
5203+
if (!this->left_->is_variable() && !this->left_->is_constant())
52045204
{
52055205
temp = Statement::make_temporary(NULL, this->left_, loc);
52065206
inserter->insert(temp);
52075207
this->left_ = Expression::make_temporary_reference(temp, loc);
52085208
}
5209-
if (!this->right_->is_variable())
5209+
if (!this->right_->is_variable() && !this->right_->is_constant())
52105210
{
52115211
temp =
52125212
Statement::make_temporary(NULL, this->right_, loc);

0 commit comments

Comments
 (0)