From 9e7f7a43e9970d9f9193cc0e237675d52f7cd806 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr>
Date: Wed, 5 May 2010 10:10:01 +0200
Subject: [PATCH] Preprocessor: never set an equal node as a temporary term
 (cherry picked from commit 49389592e7b2ea683b10a67b657639dcbde9425d)

---
 preprocessor/ExprNode.cc | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/preprocessor/ExprNode.cc b/preprocessor/ExprNode.cc
index c4e56ff035..67a38ebcc1 100644
--- a/preprocessor/ExprNode.cc
+++ b/preprocessor/ExprNode.cc
@@ -2024,10 +2024,12 @@ BinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
     }
   else
     {
-      // If the node has already been encountered, increment its ref count
-      //  and declare it as a temporary term if it is too costly
+      /* If the node has already been encountered, increment its ref count
+         and declare it as a temporary term if it is too costly (except if it is
+         an equal node: we don't want them as temporary terms) */
       reference_count[this2]++;
-      if (reference_count[this2] * cost(temporary_terms, is_matlab) > MIN_COST(is_matlab))
+      if (reference_count[this2] * cost(temporary_terms, is_matlab) > MIN_COST(is_matlab)
+          && op_code != oEqual)
         temporary_terms.insert(this2);
     }
 }
@@ -2052,7 +2054,8 @@ BinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
   else
     {
       reference_count[this2]++;
-      if (reference_count[this2] * cost(temporary_terms, false) > MIN_COST_C)
+      if (reference_count[this2] * cost(temporary_terms, false) > MIN_COST_C
+          && op_code != oEqual)
         {
           temporary_terms.insert(this2);
           v_temporary_terms[first_occurence[this2].first][first_occurence[this2].second].insert(this2);
-- 
GitLab