From: ian Date: Wed, 7 Oct 2015 17:47:45 +0000 (+0000) Subject: compiler: Don't make temporaries for constant operands. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=545ab43b95d8e7cfab7b02a1269eea5249e80445;p=thirdparty%2Fgcc.git compiler: Don't make temporaries for constant operands. Fixes golang/go#12616. Reviewed-on: https://go-review.googlesource.com/14645 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228578 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 19dcf2a64623..dda00329d065 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -651e71a729e5dcbd9dc14c1b59b6eff05bfe3d26 +a4bcd319d98ddc52b3e7d16ec87d92aad868ab05 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 56bbf619bd85..80f8b4cbb273 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -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);