Fixed bug in P4_16 programs that was making bmv2 crash

Change-Id: Ia5057b3080e55610605908cd36b399db6c50c545
diff --git a/tools/test/p4src/p4-16/p4c-out/ecmp.json b/tools/test/p4src/p4-16/p4c-out/ecmp.json
index 506db53..2a23882 100644
--- a/tools/test/p4src/p4-16/p4c-out/ecmp.json
+++ b/tools/test/p4src/p4-16/p4c-out/ecmp.json
@@ -448,7 +448,7 @@
         "column" : 38,
         "source_fragment" : "egress_port_counter"
       },
-      "size" : 254,
+      "size" : 255,
       "is_direct" : false
     },
     {
@@ -460,7 +460,7 @@
         "column" : 38,
         "source_fragment" : "ingress_port_counter"
       },
-      "size" : 254,
+      "size" : 255,
       "is_direct" : false
     }
   ],
@@ -3312,51 +3312,6 @@
                   "op" : "&",
                   "left" : {
                     "type" : "field",
-                    "value" : ["standard_metadata", "ingress_port"]
-                  },
-                  "right" : {
-                    "type" : "hexstr",
-                    "value" : "0xffffffff"
-                  }
-                }
-              }
-            }
-          ]
-        },
-        {
-          "op" : "count",
-          "parameters" : [
-            {
-              "type" : "counter_array",
-              "value" : "port_counters_control.ingress_port_counter"
-            },
-            {
-              "type" : "field",
-              "value" : ["scalars", "tmp"]
-            }
-          ],
-          "source_info" : {
-            "filename" : "include/port_counters.p4",
-            "line" : 27,
-            "column" : 12,
-            "source_fragment" : "ingress_port_counter.count((bit<32>)standard_metadata.ingress_port)"
-          }
-        },
-        {
-          "op" : "assign",
-          "parameters" : [
-            {
-              "type" : "field",
-              "value" : ["scalars", "tmp_0"]
-            },
-            {
-              "type" : "expression",
-              "value" : {
-                "type" : "expression",
-                "value" : {
-                  "op" : "&",
-                  "left" : {
-                    "type" : "field",
                     "value" : ["standard_metadata", "egress_spec"]
                   },
                   "right" : {
@@ -3377,12 +3332,12 @@
             },
             {
               "type" : "field",
-              "value" : ["scalars", "tmp_0"]
+              "value" : ["scalars", "tmp"]
             }
           ],
           "source_info" : {
             "filename" : "include/port_counters.p4",
-            "line" : 28,
+            "line" : 27,
             "column" : 12,
             "source_fragment" : "egress_port_counter.count((bit<32>)standard_metadata.egress_spec)"
           }
@@ -3395,6 +3350,58 @@
       "runtime_data" : [],
       "primitives" : [
         {
+          "op" : "assign",
+          "parameters" : [
+            {
+              "type" : "field",
+              "value" : ["scalars", "tmp_0"]
+            },
+            {
+              "type" : "expression",
+              "value" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "&",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["standard_metadata", "ingress_port"]
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0xffffffff"
+                  }
+                }
+              }
+            }
+          ]
+        },
+        {
+          "op" : "count",
+          "parameters" : [
+            {
+              "type" : "counter_array",
+              "value" : "port_counters_control.ingress_port_counter"
+            },
+            {
+              "type" : "field",
+              "value" : ["scalars", "tmp_0"]
+            }
+          ],
+          "source_info" : {
+            "filename" : "include/port_counters.p4",
+            "line" : 30,
+            "column" : 12,
+            "source_fragment" : "ingress_port_counter.count((bit<32>)standard_metadata.ingress_port)"
+          }
+        }
+      ]
+    },
+    {
+      "name" : "act_2",
+      "id" : 9,
+      "runtime_data" : [],
+      "primitives" : [
+        {
           "op" : "add_header",
           "parameters" : [
             {
@@ -3431,8 +3438,8 @@
       ]
     },
     {
-      "name" : "act_2",
-      "id" : 9,
+      "name" : "act_3",
+      "id" : 10,
       "runtime_data" : [],
       "primitives" : [
         {
@@ -3592,9 +3599,9 @@
           "direct_meters" : null,
           "action_ids" : [7],
           "actions" : ["act_0"],
-          "base_default_next" : null,
+          "base_default_next" : "node_9",
           "next_tables" : {
-            "act_0" : null
+            "act_0" : "node_9"
           },
           "default_entry" : {
             "action_id" : 7,
@@ -3602,6 +3609,29 @@
             "action_data" : [],
             "action_entry_const" : true
           }
+        },
+        {
+          "name" : "tbl_act_1",
+          "id" : 4,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [8],
+          "actions" : ["act_1"],
+          "base_default_next" : null,
+          "next_tables" : {
+            "act_1" : null
+          },
+          "default_entry" : {
+            "action_id" : 8,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
         }
       ],
       "action_profiles" : [],
@@ -3665,7 +3695,7 @@
             "filename" : "include/port_counters.p4",
             "line" : 26,
             "column" : 12,
-            "source_fragment" : "standard_metadata.egress_spec < 254"
+            "source_fragment" : "standard_metadata.egress_spec < 255"
           },
           "expression" : {
             "type" : "expression",
@@ -3677,12 +3707,38 @@
               },
               "right" : {
                 "type" : "hexstr",
-                "value" : "0x00fe"
+                "value" : "0x00ff"
+              }
+            }
+          },
+          "true_next" : "tbl_act_0",
+          "false_next" : "node_9"
+        },
+        {
+          "name" : "node_9",
+          "id" : 3,
+          "source_info" : {
+            "filename" : "include/port_counters.p4",
+            "line" : 29,
+            "column" : 12,
+            "source_fragment" : "standard_metadata.ingress_port < 255"
+          },
+          "expression" : {
+            "type" : "expression",
+            "value" : {
+              "op" : "<",
+              "left" : {
+                "type" : "field",
+                "value" : ["standard_metadata", "ingress_port"]
+              },
+              "right" : {
+                "type" : "hexstr",
+                "value" : "0x00ff"
               }
             }
           },
           "false_next" : null,
-          "true_next" : "tbl_act_0"
+          "true_next" : "tbl_act_1"
         }
       ]
     },
@@ -3695,32 +3751,9 @@
         "column" : 8,
         "source_fragment" : "egress"
       },
-      "init_table" : "tbl_act_1",
+      "init_table" : "tbl_act_2",
       "tables" : [
         {
-          "name" : "tbl_act_1",
-          "id" : 4,
-          "key" : [],
-          "match_type" : "exact",
-          "type" : "simple",
-          "max_size" : 1024,
-          "with_counters" : false,
-          "support_timeout" : false,
-          "direct_meters" : null,
-          "action_ids" : [9],
-          "actions" : ["act_2"],
-          "base_default_next" : "node_12",
-          "next_tables" : {
-            "act_2" : "node_12"
-          },
-          "default_entry" : {
-            "action_id" : 9,
-            "action_const" : true,
-            "action_data" : [],
-            "action_entry_const" : true
-          }
-        },
-        {
           "name" : "tbl_act_2",
           "id" : 5,
           "key" : [],
@@ -3730,14 +3763,37 @@
           "with_counters" : false,
           "support_timeout" : false,
           "direct_meters" : null,
-          "action_ids" : [8],
-          "actions" : ["act_1"],
-          "base_default_next" : null,
+          "action_ids" : [10],
+          "actions" : ["act_3"],
+          "base_default_next" : "node_14",
           "next_tables" : {
-            "act_1" : null
+            "act_3" : "node_14"
           },
           "default_entry" : {
-            "action_id" : 8,
+            "action_id" : 10,
+            "action_const" : true,
+            "action_data" : [],
+            "action_entry_const" : true
+          }
+        },
+        {
+          "name" : "tbl_act_3",
+          "id" : 6,
+          "key" : [],
+          "match_type" : "exact",
+          "type" : "simple",
+          "max_size" : 1024,
+          "with_counters" : false,
+          "support_timeout" : false,
+          "direct_meters" : null,
+          "action_ids" : [9],
+          "actions" : ["act_2"],
+          "base_default_next" : null,
+          "next_tables" : {
+            "act_2" : null
+          },
+          "default_entry" : {
+            "action_id" : 9,
             "action_const" : true,
             "action_data" : [],
             "action_entry_const" : true
@@ -3747,8 +3803,8 @@
       "action_profiles" : [],
       "conditionals" : [
         {
-          "name" : "node_12",
-          "id" : 3,
+          "name" : "node_14",
+          "id" : 4,
           "source_info" : {
             "filename" : "include/packet_io.p4",
             "line" : 31,
@@ -3770,7 +3826,7 @@
             }
           },
           "false_next" : null,
-          "true_next" : "tbl_act_2"
+          "true_next" : "tbl_act_3"
         }
       ]
     }