Also optimise MSB of $sub
authorEddie Hung <eddie@fpgeh.com>
Fri, 19 Jul 2019 20:11:48 +0000 (13:11 -0700)
committerEddie Hung <eddie@fpgeh.com>
Fri, 19 Jul 2019 20:11:48 +0000 (13:11 -0700)
passes/opt/wreduce.cc

index e8c2cb7265363575a7c2baeac306938cf432a6c7..dff1c53702bf39f25fb9f0d578910de15c0f05dd 100644 (file)
@@ -342,9 +342,9 @@ struct WreduceWorker
                        }
                }
 
-               if (cell->type.in("$pos", "$add", "$mul", "$and", "$or", "$xor"))
+               if (cell->type.in("$pos", "$add", "$mul", "$and", "$or", "$xor", "$sub"))
                {
-                       bool is_signed = cell->getParam("\\A_SIGNED").as_bool();
+                       bool is_signed = cell->getParam("\\A_SIGNED").as_bool() || cell->type == "$sub";
 
                        int a_size = 0, b_size = 0;
                        if (cell->hasPort("\\A")) a_size = GetSize(cell->getPort("\\A"));
@@ -352,7 +352,7 @@ struct WreduceWorker
 
                        int max_y_size = max(a_size, b_size);
 
-                       if (cell->type == "$add")
+                       if (cell->type.in("$add", "$sub"))
                                max_y_size++;
 
                        if (cell->type == "$mul")