From 0f8b2d6bc01bec6844f260ba14b7eaa43a6dfbb5 Mon Sep 17 00:00:00 2001
From: Aaron Councilman <aaronjc4@illinois.edu>
Date: Fri, 21 Feb 2025 09:21:06 -0600
Subject: [PATCH] Fix interpreter

---
 .../hercules_interpreter/src/interpreter.rs    | 17 +++++++++++++----
 .../hercules_interpreter/src/value.rs          |  3 +++
 hercules_test/test_inputs/call.hir             |  5 +++--
 hercules_test/test_inputs/call_dc_params.hir   |  5 +++--
 hercules_test/test_inputs/ccp_example.hir      |  8 ++++----
 .../fork_fission/inner_loop.hir                |  6 +++---
 .../test_inputs/forkify/alternate_bounds.hir   |  6 +++---
 .../test_inputs/forkify/broken_sum.hir         |  6 +++---
 .../forkify/control_after_condition.hir        | 10 +++++-----
 .../forkify/control_before_condition.hir       | 10 +++++-----
 .../expected_fails.hir/bad_3nest_return.hir    | 12 ++++++------
 .../expected_fails.hir/bad_loop_tid_sum.hir    |  6 +++---
 .../test_inputs/forkify/inner_fork.hir         |  6 +++---
 .../test_inputs/forkify/inner_fork_complex.hir | 10 +++++-----
 .../test_inputs/forkify/loop_array_sum.hir     |  6 +++---
 .../test_inputs/forkify/loop_simple_iv.hir     |  6 +++---
 hercules_test/test_inputs/forkify/loop_sum.hir |  6 +++---
 .../test_inputs/forkify/loop_tid_sum.hir       |  6 +++---
 .../test_inputs/forkify/merged_phi_cycle.hir   |  6 +++---
 .../test_inputs/forkify/nested_loop2.hir       | 10 +++++-----
 .../test_inputs/forkify/nested_tid_sum.hir     | 10 +++++-----
 .../test_inputs/forkify/nested_tid_sum_2.hir   | 10 +++++-----
 .../test_inputs/forkify/phi_loop4.hir          |  6 +++---
 .../test_inputs/forkify/split_phi_cycle.hir    |  6 +++---
 .../test_inputs/forkify/super_nested_loop.hir  | 12 ++++++------
 .../loop_analysis/alternate_bounds.hir         |  6 +++---
 .../alternate_bounds_internal_control.hir      |  6 +++---
 .../alternate_bounds_internal_control2.hir     |  6 +++---
 .../alternate_bounds_nested_do_loop.hir        | 10 +++++-----
 .../alternate_bounds_nested_do_loop2.hir       | 10 +++++-----
 .../alternate_bounds_nested_do_loop_array.hir  | 10 +++++-----
 ...alternate_bounds_nested_do_loop_guarded.hir | 18 +++++++++---------
 .../alternate_bounds_use_after_loop.hir        |  6 +++---
 .../alternate_bounds_use_after_loop2.hir       |  6 +++---
 .../alternate_bounds_use_after_loop_no_tid.hir |  6 +++---
 ...alternate_bounds_use_after_loop_no_tid2.hir |  6 +++---
 .../test_inputs/loop_analysis/broken_sum.hir   |  6 +++---
 .../loop_analysis/do_loop_far_guard.hir        |  6 +++---
 .../loop_analysis/do_loop_immediate_guard.hir  | 10 +++++-----
 .../loop_analysis/do_loop_no_guard.hir         |  6 +++---
 .../loop_analysis/do_while_separate_body.hir   |  6 +++---
 .../loop_analysis/do_while_separate_body2.hir  |  6 +++---
 .../loop_analysis/loop_array_sum.hir           |  6 +++---
 .../loop_analysis/loop_body_count.hir          |  6 +++---
 .../test_inputs/loop_analysis/loop_sum.hir     |  6 +++---
 .../loop_analysis/loop_trip_count.hir          |  6 +++---
 .../loop_analysis/loop_trip_count_tuple.hir    |  6 +++---
 hercules_test/test_inputs/simple2.hir          |  6 +++---
 hercules_test/test_inputs/strset.hir           |  4 ++--
 hercules_test/test_inputs/sum_int1.hir         |  6 +++---
 hercules_test/test_inputs/sum_int2.hir         |  8 ++++----
 51 files changed, 196 insertions(+), 182 deletions(-)

diff --git a/hercules_test/hercules_interpreter/src/interpreter.rs b/hercules_test/hercules_interpreter/src/interpreter.rs
index 2e352644..f9d666a5 100644
--- a/hercules_test/hercules_interpreter/src/interpreter.rs
+++ b/hercules_test/hercules_interpreter/src/interpreter.rs
@@ -529,6 +529,13 @@ impl<'a> FunctionExecutionState<'a> {
 
                 state.run()
             }
+            Node::DataProjection { data, selection } => {
+                let data = self.handle_data(token, *data);
+                let InterpreterVal::MultiReturn(vs) = data else {
+                    panic!();
+                };
+                vs[*selection].clone()
+            }
             Node::Read { collect, indices } => {
                 let collection = self.handle_data(token, *collect);
                 if let InterpreterVal::Undef(_) = collection {
@@ -745,7 +752,7 @@ impl<'a> FunctionExecutionState<'a> {
                         .succs(ctrl_token.curr)
                         .find(|n| {
                             self.get_function().nodes[n.idx()]
-                                .try_projection(cond)
+                                .try_control_projection(cond)
                                 .is_some()
                         })
                         .expect("PANIC: No outgoing valid outgoing edge.");
@@ -753,7 +760,7 @@ impl<'a> FunctionExecutionState<'a> {
                     let ctrl_token = ctrl_token.moved_to(next);
                     vec![ctrl_token]
                 }
-                Node::Projection { .. } => {
+                Node::ControlProjection { .. } => {
                     let next: NodeID = self
                         .get_control_subgraph()
                         .succs(ctrl_token.curr)
@@ -861,8 +868,10 @@ impl<'a> FunctionExecutionState<'a> {
                     }
                 }
                 Node::Return { control: _, data } => {
-                    let result = self.handle_data(&ctrl_token, *data);
-                    break 'outer result;
+                    let results = data.iter()
+                        .map(|data| self.handle_data(&ctrl_token, *data))
+                        .collect();
+                    break 'outer InterpreterVal::MultiReturn(results);
                 }
                 _ => {
                     panic!("PANIC: Unexpected node in control subgraph {:?}", node);
diff --git a/hercules_test/hercules_interpreter/src/value.rs b/hercules_test/hercules_interpreter/src/value.rs
index dfc290b2..0f5716e7 100644
--- a/hercules_test/hercules_interpreter/src/value.rs
+++ b/hercules_test/hercules_interpreter/src/value.rs
@@ -36,6 +36,8 @@ pub enum InterpreterVal {
     // These can be freely? casted
     DynamicConstant(usize),
     ThreadID(usize),
+
+    MultiReturn(Box<[InterpreterVal]>),
 }
 
 #[derive(Clone)]
@@ -848,6 +850,7 @@ impl<'a> InterpreterVal {
                     Type::Product(_) => todo!(),
                     Type::Summation(_) => todo!(),
                     Type::Array(type_id, _) => todo!(),
+                    Type::MultiReturn(_) => todo!(),
                 }
             }
             (_, Self::Undef(v)) => InterpreterVal::Undef(v),
diff --git a/hercules_test/test_inputs/call.hir b/hercules_test/test_inputs/call.hir
index 44748934..0ebf7c7d 100644
--- a/hercules_test/test_inputs/call.hir
+++ b/hercules_test/test_inputs/call.hir
@@ -1,7 +1,8 @@
 fn myfunc(x: i32) -> i32
-  y = call(add, x, x)
+  cy = call(add, x, x)
+  y = data_projection(cy, 0)
   r = return(start, y)
 
 fn add(x: i32, y: i32) -> i32
   w = add(x, y)
-  r = return(start, w)
\ No newline at end of file
+  r = return(start, w)
diff --git a/hercules_test/test_inputs/call_dc_params.hir b/hercules_test/test_inputs/call_dc_params.hir
index 5ccf2686..b8da9791 100644
--- a/hercules_test/test_inputs/call_dc_params.hir
+++ b/hercules_test/test_inputs/call_dc_params.hir
@@ -1,9 +1,10 @@
 fn myfunc(x: u64) -> u64
-  y = call<10, 4>(add, x, x)
+  cy = call<10, 4>(add, x, x)
+  y = data_projection(cy, 0)
   r = return(start, y)
 
 fn add<2>(x: u64, y: u64) -> u64
   b = dynamic_constant(#1)
   r = return(start, z)
   w = add(x, y)
-  z = add(b, w)
\ No newline at end of file
+  z = add(b, w)
diff --git a/hercules_test/test_inputs/ccp_example.hir b/hercules_test/test_inputs/ccp_example.hir
index 25b7379e..f8004b63 100644
--- a/hercules_test/test_inputs/ccp_example.hir
+++ b/hercules_test/test_inputs/ccp_example.hir
@@ -6,14 +6,14 @@ fn tricky(x: i32) -> i32
   val = phi(loop, one, later_val)
   b = ne(one, val)
   if1 = if(loop, b)
-  if1_false = projection(if1, 0)
-  if1_true = projection(if1, 1)
+  if1_false = control_projection(if1, 0)
+  if1_true = control_projection(if1, 1)
   middle = region(if1_false, if1_true)
   inter_val = sub(two, val)
   later_val = phi(middle, inter_val, two)
   idx_dec = sub(idx, one)
   cond = gte(idx_dec, one)
   if2 = if(middle, cond)
-  if2_false = projection(if2, 0)
-  if2_true = projection(if2, 1)
+  if2_false = control_projection(if2, 0)
+  if2_true = control_projection(if2, 1)
   r = return(if2_false, later_val)
diff --git a/hercules_test/test_inputs/fork_transforms/fork_fission/inner_loop.hir b/hercules_test/test_inputs/fork_transforms/fork_fission/inner_loop.hir
index 0cc13b2f..b7458a43 100644
--- a/hercules_test/test_inputs/fork_transforms/fork_fission/inner_loop.hir
+++ b/hercules_test/test_inputs/fork_transforms/fork_fission/inner_loop.hir
@@ -11,8 +11,8 @@ fn fun<2>(x: u64) -> u64
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   j = join(if_false)
   tid = thread_id(f, 0)
   add1 = add(reduce1, idx)
@@ -20,4 +20,4 @@ fn fun<2>(x: u64) -> u64
   add2 = add(reduce2, idx_inc)
   reduce2 =  reduce(j, zero, add2)
   out1 = add(reduce1, reduce2)
-  z = return(j, out1)
\ No newline at end of file
+  z = return(j, out1)
diff --git a/hercules_test/test_inputs/forkify/alternate_bounds.hir b/hercules_test/test_inputs/forkify/alternate_bounds.hir
index 4a9ba015..7de8cf1e 100644
--- a/hercules_test/test_inputs/forkify/alternate_bounds.hir
+++ b/hercules_test/test_inputs/forkify/alternate_bounds.hir
@@ -11,6 +11,6 @@ fn sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red_add)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red_add)
diff --git a/hercules_test/test_inputs/forkify/broken_sum.hir b/hercules_test/test_inputs/forkify/broken_sum.hir
index d15ef561..75b12350 100644
--- a/hercules_test/test_inputs/forkify/broken_sum.hir
+++ b/hercules_test/test_inputs/forkify/broken_sum.hir
@@ -11,6 +11,6 @@ fn sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red_add)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red_add)
diff --git a/hercules_test/test_inputs/forkify/control_after_condition.hir b/hercules_test/test_inputs/forkify/control_after_condition.hir
index db40225b..a1a97fba 100644
--- a/hercules_test/test_inputs/forkify/control_after_condition.hir
+++ b/hercules_test/test_inputs/forkify/control_after_condition.hir
@@ -11,8 +11,8 @@ fn alt_sum<1>(a: array(i32, #0)) -> i32
   rem = rem(idx, two_idx)
   odd = eq(rem, one_idx)
   negate_if = if(loop_continue, odd)
-  negate_if_false = projection(negate_if, 0)
-  negate_if_true = projection(negate_if, 1)
+  negate_if_false = control_projection(negate_if, 0)
+  negate_if_true = control_projection(negate_if, 1)
   negate_bottom = region(negate_if_false, negate_if_true)
   read = read(a, position(idx))
   read_neg = neg(read)
@@ -20,6 +20,6 @@ fn alt_sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read_phi)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  loop_exit = projection(if, 0)
-  loop_continue = projection(if, 1)
-  r = return(loop_exit, red)
\ No newline at end of file
+  loop_exit = control_projection(if, 0)
+  loop_continue = control_projection(if, 1)
+  r = return(loop_exit, red)
diff --git a/hercules_test/test_inputs/forkify/control_before_condition.hir b/hercules_test/test_inputs/forkify/control_before_condition.hir
index f24b565a..e351d714 100644
--- a/hercules_test/test_inputs/forkify/control_before_condition.hir
+++ b/hercules_test/test_inputs/forkify/control_before_condition.hir
@@ -11,8 +11,8 @@ fn alt_sum<1>(a: array(i32, #0)) -> i32
   rem = rem(idx, two_idx)
   odd = eq(rem, one_idx)
   negate_if = if(loop, odd)
-  negate_if_false = projection(negate_if, 0)
-  negate_if_true = projection(negate_if, 1)
+  negate_if_false = control_projection(negate_if, 0)
+  negate_if_true = control_projection(negate_if, 1)
   negate_bottom = region(negate_if_false, negate_if_true)
   read = read(a, position(idx))
   read_neg = neg(read)
@@ -20,6 +20,6 @@ fn alt_sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read_phi)
   in_bounds = lt(idx, bound)
   if = if(negate_bottom, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red)
diff --git a/hercules_test/test_inputs/forkify/expected_fails.hir/bad_3nest_return.hir b/hercules_test/test_inputs/forkify/expected_fails.hir/bad_3nest_return.hir
index f5ec4370..7599e6ec 100644
--- a/hercules_test/test_inputs/forkify/expected_fails.hir/bad_3nest_return.hir
+++ b/hercules_test/test_inputs/forkify/expected_fails.hir/bad_3nest_return.hir
@@ -16,18 +16,18 @@ fn loop<3>(a: u32) -> i32
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx, outer_bound)
   inner_if = if(inner_loop, inner_in_bounds)
-  inner_if_false = projection(inner_if, 0)
-  inner_if_true = projection(inner_if, 1)
+  inner_if_false = control_projection(inner_if, 0)
+  inner_if_true = control_projection(inner_if, 1)
   outer_if = if(outer_loop, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
-  outer_if_true = projection(outer_if, 1)
+  outer_if_false = control_projection(outer_if, 0)
+  outer_if_true = control_projection(outer_if, 1)
   outer_bound = dynamic_constant(#1)
   outer_outer_bound = dynamic_constant(#2)
   outer_outer_loop = region(start, outer_if_false)
   outer_outer_var = phi(outer_outer_loop, zero_var, outer_var)
   outer_outer_if  = if(outer_outer_loop, outer_outer_in_bounds)
-  outer_outer_if_false = projection(outer_outer_if, 0)
-  outer_outer_if_true = projection(outer_outer_if, 1)
+  outer_outer_if_false = control_projection(outer_outer_if, 0)
+  outer_outer_if_true = control_projection(outer_outer_if, 1)
   outer_outer_idx = phi(outer_outer_loop, zero_idx, outer_outer_idx_inc, outer_outer_idx)
   outer_outer_idx_inc = add(outer_outer_idx, one_idx)
   outer_outer_in_bounds = lt(outer_outer_idx, outer_outer_bound)
diff --git a/hercules_test/test_inputs/forkify/expected_fails.hir/bad_loop_tid_sum.hir b/hercules_test/test_inputs/forkify/expected_fails.hir/bad_loop_tid_sum.hir
index 8dda179b..8f7d5e48 100644
--- a/hercules_test/test_inputs/forkify/expected_fails.hir/bad_loop_tid_sum.hir
+++ b/hercules_test/test_inputs/forkify/expected_fails.hir/bad_loop_tid_sum.hir
@@ -11,6 +11,6 @@ fn loop<1>(a: u64) -> u64
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, var_inc)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, var_inc)
diff --git a/hercules_test/test_inputs/forkify/inner_fork.hir b/hercules_test/test_inputs/forkify/inner_fork.hir
index e2c96a68..c603dc42 100644
--- a/hercules_test/test_inputs/forkify/inner_fork.hir
+++ b/hercules_test/test_inputs/forkify/inner_fork.hir
@@ -6,7 +6,7 @@ fn loop<2>(a: u32) -> i32
   inner_bound = dynamic_constant(#0)
   outer_bound = dynamic_constant(#1)
   outer_loop = region(start, inner_join)
-  outer_if_true = projection(outer_if, 1)
+  outer_if_true = control_projection(outer_if, 1)
   inner_fork = fork(outer_if_true, #0)
   inner_join = join(inner_fork)
   outer_var = phi(outer_loop, zero_var, inner_var)
@@ -17,6 +17,6 @@ fn loop<2>(a: u32) -> i32
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx, outer_bound)
   outer_if = if(outer_loop, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
+  outer_if_false = control_projection(outer_if, 0)
   r = return(outer_if_false, outer_var)
- 
\ No newline at end of file
+ 
diff --git a/hercules_test/test_inputs/forkify/inner_fork_complex.hir b/hercules_test/test_inputs/forkify/inner_fork_complex.hir
index 91eb00fa..c9488f7f 100644
--- a/hercules_test/test_inputs/forkify/inner_fork_complex.hir
+++ b/hercules_test/test_inputs/forkify/inner_fork_complex.hir
@@ -8,14 +8,14 @@ fn loop<2>(a: u32) -> u64
   inner_bound = dynamic_constant(#0)
   outer_bound = dynamic_constant(#1)
   outer_loop = region(start, inner_condition_true_projection, inner_condition_false_projection )
-  outer_if_true = projection(outer_if, 1)
+  outer_if_true = control_projection(outer_if, 1)
   other_phi_weird = phi(outer_loop, zero_var, inner_var, other_phi_weird)
   inner_fork = fork(outer_if_true, #0)
   inner_join = join(inner_fork)
   inner_condition_eq = eq(outer_idx, two)
   inner_condition_if = if(inner_join, inner_condition_eq)
-  inner_condition_true_projection = projection(inner_condition_if, 1)
-  inner_condition_false_projection = projection(inner_condition_if, 0)
+  inner_condition_true_projection = control_projection(inner_condition_if, 1)
+  inner_condition_false_projection = control_projection(inner_condition_if, 0)
   outer_var = phi(outer_loop, zero_var, inner_var, inner_var)
   inner_var = reduce(inner_join, outer_var, inner_var_inc)
   inner_var_inc = add(inner_var, inner_var_inc_3)
@@ -26,7 +26,7 @@ fn loop<2>(a: u32) -> u64
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx, outer_bound)
   outer_if = if(outer_loop, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
+  outer_if_false = control_projection(outer_if, 0)
   ret_val = add(outer_var, other_phi_weird)
   r = return(outer_if_false, ret_val)
- 
\ No newline at end of file
+ 
diff --git a/hercules_test/test_inputs/forkify/loop_array_sum.hir b/hercules_test/test_inputs/forkify/loop_array_sum.hir
index f9972b59..884d22d4 100644
--- a/hercules_test/test_inputs/forkify/loop_array_sum.hir
+++ b/hercules_test/test_inputs/forkify/loop_array_sum.hir
@@ -11,6 +11,6 @@ fn sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red)
diff --git a/hercules_test/test_inputs/forkify/loop_simple_iv.hir b/hercules_test/test_inputs/forkify/loop_simple_iv.hir
index c25b9a2c..c671b94c 100644
--- a/hercules_test/test_inputs/forkify/loop_simple_iv.hir
+++ b/hercules_test/test_inputs/forkify/loop_simple_iv.hir
@@ -7,6 +7,6 @@ fn loop<1>(a: u32) -> u64
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, idx)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, idx)
diff --git a/hercules_test/test_inputs/forkify/loop_sum.hir b/hercules_test/test_inputs/forkify/loop_sum.hir
index fd9c4deb..a236ddf7 100644
--- a/hercules_test/test_inputs/forkify/loop_sum.hir
+++ b/hercules_test/test_inputs/forkify/loop_sum.hir
@@ -11,6 +11,6 @@ fn loop<1>(a: u32) -> i32
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, var)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, var)
diff --git a/hercules_test/test_inputs/forkify/loop_tid_sum.hir b/hercules_test/test_inputs/forkify/loop_tid_sum.hir
index 2d3ca34d..6a1e2c56 100644
--- a/hercules_test/test_inputs/forkify/loop_tid_sum.hir
+++ b/hercules_test/test_inputs/forkify/loop_tid_sum.hir
@@ -11,6 +11,6 @@ fn loop<1>(a: u64) -> u64
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, var)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, var)
diff --git a/hercules_test/test_inputs/forkify/merged_phi_cycle.hir b/hercules_test/test_inputs/forkify/merged_phi_cycle.hir
index cee473a0..2b276d3e 100644
--- a/hercules_test/test_inputs/forkify/merged_phi_cycle.hir
+++ b/hercules_test/test_inputs/forkify/merged_phi_cycle.hir
@@ -13,6 +13,6 @@ fn sum<1>(a: i32) -> u64
   second_red_add_2 = add(first_red_add, two)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, first_red_add_2)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, first_red_add_2)
diff --git a/hercules_test/test_inputs/forkify/nested_loop2.hir b/hercules_test/test_inputs/forkify/nested_loop2.hir
index 0f29ec74..c3c7d8e5 100644
--- a/hercules_test/test_inputs/forkify/nested_loop2.hir
+++ b/hercules_test/test_inputs/forkify/nested_loop2.hir
@@ -17,9 +17,9 @@ fn loop<2>(a: u32) -> i32
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx, outer_bound)
   inner_if = if(inner_loop, inner_in_bounds)
-  inner_if_false = projection(inner_if, 0)
-  inner_if_true = projection(inner_if, 1)
+  inner_if_false = control_projection(inner_if, 0)
+  inner_if_true = control_projection(inner_if, 1)
   outer_if = if(outer_loop, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
-  outer_if_true = projection(outer_if, 1)
-  r = return(outer_if_false, outer_var)
\ No newline at end of file
+  outer_if_false = control_projection(outer_if, 0)
+  outer_if_true = control_projection(outer_if, 1)
+  r = return(outer_if_false, outer_var)
diff --git a/hercules_test/test_inputs/forkify/nested_tid_sum.hir b/hercules_test/test_inputs/forkify/nested_tid_sum.hir
index 5539202d..f7e4bda4 100644
--- a/hercules_test/test_inputs/forkify/nested_tid_sum.hir
+++ b/hercules_test/test_inputs/forkify/nested_tid_sum.hir
@@ -17,9 +17,9 @@ fn loop<2>(a: u32) -> u64
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx, outer_bound)
   inner_if = if(inner_loop, inner_in_bounds)
-  inner_if_false = projection(inner_if, 0)
-  inner_if_true = projection(inner_if, 1)
+  inner_if_false = control_projection(inner_if, 0)
+  inner_if_true = control_projection(inner_if, 1)
   outer_if = if(outer_loop, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
-  outer_if_true = projection(outer_if, 1)
-  r = return(outer_if_false, outer_var)
\ No newline at end of file
+  outer_if_false = control_projection(outer_if, 0)
+  outer_if_true = control_projection(outer_if, 1)
+  r = return(outer_if_false, outer_var)
diff --git a/hercules_test/test_inputs/forkify/nested_tid_sum_2.hir b/hercules_test/test_inputs/forkify/nested_tid_sum_2.hir
index 9221fd47..50634a2c 100644
--- a/hercules_test/test_inputs/forkify/nested_tid_sum_2.hir
+++ b/hercules_test/test_inputs/forkify/nested_tid_sum_2.hir
@@ -18,9 +18,9 @@ fn loop<2>(a: u32) -> u64
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx, outer_bound)
   inner_if = if(inner_loop, inner_in_bounds)
-  inner_if_false = projection(inner_if, 0)
-  inner_if_true = projection(inner_if, 1)
+  inner_if_false = control_projection(inner_if, 0)
+  inner_if_true = control_projection(inner_if, 1)
   outer_if = if(outer_loop, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
-  outer_if_true = projection(outer_if, 1)
-  r = return(outer_if_false, outer_var)
\ No newline at end of file
+  outer_if_false = control_projection(outer_if, 0)
+  outer_if_true = control_projection(outer_if, 1)
+  r = return(outer_if_false, outer_var)
diff --git a/hercules_test/test_inputs/forkify/phi_loop4.hir b/hercules_test/test_inputs/forkify/phi_loop4.hir
index e69ecc3d..9ce594da 100644
--- a/hercules_test/test_inputs/forkify/phi_loop4.hir
+++ b/hercules_test/test_inputs/forkify/phi_loop4.hir
@@ -11,6 +11,6 @@ fn loop<1>(a: u32) -> i32
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, var_inc)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, var_inc)
diff --git a/hercules_test/test_inputs/forkify/split_phi_cycle.hir b/hercules_test/test_inputs/forkify/split_phi_cycle.hir
index 96de73c8..a233230b 100644
--- a/hercules_test/test_inputs/forkify/split_phi_cycle.hir
+++ b/hercules_test/test_inputs/forkify/split_phi_cycle.hir
@@ -11,6 +11,6 @@ fn sum<1>(a: i32) -> u64
   first_red_add_2 = add(first_red_add, two)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, first_red_add_2)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, first_red_add_2)
diff --git a/hercules_test/test_inputs/forkify/super_nested_loop.hir b/hercules_test/test_inputs/forkify/super_nested_loop.hir
index 6853efbf..b568b85a 100644
--- a/hercules_test/test_inputs/forkify/super_nested_loop.hir
+++ b/hercules_test/test_inputs/forkify/super_nested_loop.hir
@@ -16,18 +16,18 @@ fn loop<3>(a: u32) -> i32
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx, outer_bound)
   inner_if = if(inner_loop, inner_in_bounds)
-  inner_if_false = projection(inner_if, 0)
-  inner_if_true = projection(inner_if, 1)
+  inner_if_false = control_projection(inner_if, 0)
+  inner_if_true = control_projection(inner_if, 1)
   outer_if = if(outer_loop, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
-  outer_if_true = projection(outer_if, 1)
+  outer_if_false = control_projection(outer_if, 0)
+  outer_if_true = control_projection(outer_if, 1)
   outer_bound = dynamic_constant(#1)
   outer_outer_bound = dynamic_constant(#2)
   outer_outer_loop = region(start, outer_if_false)
   outer_outer_var = phi(outer_outer_loop, zero_var, outer_var)
   outer_outer_if  = if(outer_outer_loop, outer_outer_in_bounds)
-  outer_outer_if_false = projection(outer_outer_if, 0)
-  outer_outer_if_true = projection(outer_outer_if, 1)
+  outer_outer_if_false = control_projection(outer_outer_if, 0)
+  outer_outer_if_true = control_projection(outer_outer_if, 1)
   outer_outer_idx = phi(outer_outer_loop, zero_idx, outer_outer_idx_inc, outer_outer_idx)
   outer_outer_idx_inc = add(outer_outer_idx, one_idx)
   outer_outer_in_bounds = lt(outer_outer_idx, outer_outer_bound)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds.hir
index 4df92a18..a6ae209b 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds.hir
@@ -9,6 +9,6 @@ fn sum<1>(a: u32) -> u64
   red_add = add(red, one_idx)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_internal_control.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_internal_control.hir
index 8b4431bf..9bd6b626 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_internal_control.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_internal_control.hir
@@ -15,9 +15,9 @@ fn sum<1>(a: u64) -> u64
   red_add2 = add(red, inner_phi)
   in_bounds = lt(idx_inc, bound)
   if = if(inner_ctrl, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   plus_ten = add(red_add, ten)
   red_add_2_plus_blah = add(red2, plus_ten)
   final_add = add(inner_phi, red_add_2_plus_blah)
-  r = return(if_false, final_add)
\ No newline at end of file
+  r = return(if_false, final_add)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_internal_control2.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_internal_control2.hir
index f4adf643..2801a165 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_internal_control2.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_internal_control2.hir
@@ -13,9 +13,9 @@ fn sum<1>(a: u64) -> u64
   red_add = add(red, two)
   in_bounds = lt(idx_inc, bound)
   if = if(inner_ctrl, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   plus_ten = add(red_add, ten)
   red_add_2_plus_blah = add(inner_phi, plus_ten)
   final_add = add(inner_phi, red_add_2_plus_blah)
-  r = return(if_false, final_add)
\ No newline at end of file
+  r = return(if_false, final_add)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop.hir
index 52f70172..edbec0c5 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop.hir
@@ -20,9 +20,9 @@ fn loop<2>(a: u64) -> u64
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx_inc, outer_bound)
   inner_if = if(inner_loop, inner_in_bounds)
-  inner_if_false = projection(inner_if, 0)
-  inner_if_true = projection(inner_if, 1)
+  inner_if_false = control_projection(inner_if, 0)
+  inner_if_true = control_projection(inner_if, 1)
   outer_if = if(inner_if_false, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
-  outer_if_true = projection(outer_if, 1)
-  r = return(outer_if_false, inner_var_inc)
\ No newline at end of file
+  outer_if_false = control_projection(outer_if, 0)
+  outer_if_true = control_projection(outer_if, 1)
+  r = return(outer_if_false, inner_var_inc)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop2.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop2.hir
index f295b391..4e81871c 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop2.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop2.hir
@@ -17,9 +17,9 @@ fn loop<2>(a: u32) -> i32
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx_inc, outer_bound)
   inner_if = if(inner_loop, inner_in_bounds)
-  inner_if_false = projection(inner_if, 0)
-  inner_if_true = projection(inner_if, 1)
+  inner_if_false = control_projection(inner_if, 0)
+  inner_if_true = control_projection(inner_if, 1)
   outer_if = if(inner_if_false, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
-  outer_if_true = projection(outer_if, 1)
-  r = return(outer_if_false, inner_var_inc)
\ No newline at end of file
+  outer_if_false = control_projection(outer_if, 0)
+  outer_if_true = control_projection(outer_if, 1)
+  r = return(outer_if_false, inner_var_inc)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop_array.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop_array.hir
index e5401779..98477c91 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop_array.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop_array.hir
@@ -20,9 +20,9 @@ fn loop<2>(a: array(u64, #1)) -> u64
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx_inc, outer_bound)
   inner_if = if(inner_loop, inner_in_bounds)
-  inner_if_false = projection(inner_if, 0)
-  inner_if_true = projection(inner_if, 1)
+  inner_if_false = control_projection(inner_if, 0)
+  inner_if_true = control_projection(inner_if, 1)
   outer_if = if(inner_if_false, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
-  outer_if_true = projection(outer_if, 1)
-  r = return(outer_if_false, inner_var_inc)
\ No newline at end of file
+  outer_if_false = control_projection(outer_if, 0)
+  outer_if_true = control_projection(outer_if, 1)
+  r = return(outer_if_false, inner_var_inc)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop_guarded.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop_guarded.hir
index b979ad42..eee77b6c 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop_guarded.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_nested_do_loop_guarded.hir
@@ -5,8 +5,8 @@ fn loop<2>(a: u64) -> u64
   one_var = constant(u64, 1)
   ten = constant(u64, 10)
   outer_guard_if = if(start, outer_guard_lt)
-  outer_guard_if_false = projection(outer_guard_if, 0)
-  outer_guard_if_true = projection(outer_guard_if, 1)
+  outer_guard_if_false = control_projection(outer_guard_if, 0)
+  outer_guard_if_true = control_projection(outer_guard_if, 1)
   outer_guard_lt = lt(zero_idx, outer_bound)
   outer_join = region(outer_guard_if_false, outer_if_false)
   outer_join_var = phi(outer_join, zero_idx, join_var)
@@ -16,8 +16,8 @@ fn loop<2>(a: u64) -> u64
   inner_loop = region(guard_if_true, inner_if_true)
   guard_lt = lt(zero_idx, inner_bound)
   guard_if = if(outer_loop, guard_lt)
-  guard_if_true = projection(guard_if, 1)
-  guard_if_false = projection(guard_if, 0)
+  guard_if_true = control_projection(guard_if, 1)
+  guard_if_false = control_projection(guard_if, 0)
   guard_join = region(guard_if_false, inner_if_false)
   inner_idx = phi(inner_loop, zero_idx, inner_idx_inc)
   inner_idx_inc = add(inner_idx, one_idx)
@@ -26,15 +26,15 @@ fn loop<2>(a: u64) -> u64
   outer_idx_inc = add(outer_idx, one_idx)
   outer_in_bounds = lt(outer_idx_inc, outer_bound)
   inner_if = if(inner_loop, inner_in_bounds)
-  inner_if_false = projection(inner_if, 0)
-  inner_if_true = projection(inner_if, 1)
+  inner_if_false = control_projection(inner_if, 0)
+  inner_if_true = control_projection(inner_if, 1)
   outer_if = if(guard_join, outer_in_bounds)
-  outer_if_false = projection(outer_if, 0)
-  outer_if_true = projection(outer_if, 1)
+  outer_if_false = control_projection(outer_if, 0)
+  outer_if_true = control_projection(outer_if, 1)
   outer_var = phi(outer_loop, zero_var, join_var)
   inner_var = phi(inner_loop, outer_var, inner_var_inc)
   blah = mul(outer_idx, ten)
   blah2 = add(blah, inner_idx)
   inner_var_inc = add(inner_var, blah2)
   join_var = phi(guard_join, outer_var, inner_var_inc)
-  r = return(outer_join, outer_join_var)
\ No newline at end of file
+  r = return(outer_join, outer_join_var)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop.hir
index 2fe4ca57..4a6e8cd6 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop.hir
@@ -13,9 +13,9 @@ fn sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   plus_ten = add(red_add, ten)
   mult = mul(read, three)
   final = add(plus_ten, mult)
-  r = return(if_false, final)
\ No newline at end of file
+  r = return(if_false, final)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop2.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop2.hir
index 760ae5ad..f735c8c6 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop2.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop2.hir
@@ -13,9 +13,9 @@ fn sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   plus_ten = add(red, ten)
   mult = mul(read, three)
   final = add(plus_ten, mult)
-  r = return(if_false, final)
\ No newline at end of file
+  r = return(if_false, final)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop_no_tid.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop_no_tid.hir
index 4b937509..c2f5e30a 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop_no_tid.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop_no_tid.hir
@@ -11,7 +11,7 @@ fn sum<1>(a: u64) -> u64
   red_add = add(red, two)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   plus_ten = add(red_add, ten)
-  r = return(if_false, plus_ten)
\ No newline at end of file
+  r = return(if_false, plus_ten)
diff --git a/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop_no_tid2.hir b/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop_no_tid2.hir
index fd06eb7d..f7a4af06 100644
--- a/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop_no_tid2.hir
+++ b/hercules_test/test_inputs/loop_analysis/alternate_bounds_use_after_loop_no_tid2.hir
@@ -12,8 +12,8 @@ fn sum<1>(a: u64) -> u64
   blah = phi(loop, zero_idx, red_add)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   plus_ten = add(red_add, ten)
   plus_blah = add(blah, red_add)
-  r = return(if_false, plus_blah)
\ No newline at end of file
+  r = return(if_false, plus_blah)
diff --git a/hercules_test/test_inputs/loop_analysis/broken_sum.hir b/hercules_test/test_inputs/loop_analysis/broken_sum.hir
index d15ef561..75b12350 100644
--- a/hercules_test/test_inputs/loop_analysis/broken_sum.hir
+++ b/hercules_test/test_inputs/loop_analysis/broken_sum.hir
@@ -11,6 +11,6 @@ fn sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red_add)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red_add)
diff --git a/hercules_test/test_inputs/loop_analysis/do_loop_far_guard.hir b/hercules_test/test_inputs/loop_analysis/do_loop_far_guard.hir
index 4df92a18..a6ae209b 100644
--- a/hercules_test/test_inputs/loop_analysis/do_loop_far_guard.hir
+++ b/hercules_test/test_inputs/loop_analysis/do_loop_far_guard.hir
@@ -9,6 +9,6 @@ fn sum<1>(a: u32) -> u64
   red_add = add(red, one_idx)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red)
diff --git a/hercules_test/test_inputs/loop_analysis/do_loop_immediate_guard.hir b/hercules_test/test_inputs/loop_analysis/do_loop_immediate_guard.hir
index a4732cde..bfdb673f 100644
--- a/hercules_test/test_inputs/loop_analysis/do_loop_immediate_guard.hir
+++ b/hercules_test/test_inputs/loop_analysis/do_loop_immediate_guard.hir
@@ -4,8 +4,8 @@ fn sum<1>(a: u64) -> u64
   bound = dynamic_constant(#0)
   guard_lt = lt(zero_idx, bound)
   guard = if(start, guard_lt)
-  guard_true = projection(guard, 1)
-  guard_false = projection(guard, 0)
+  guard_true = control_projection(guard, 1)
+  guard_false = control_projection(guard, 0)
   loop = region(guard_true, if_true)
   inner_side_effect = region(loop)
   idx = phi(loop, zero_idx, idx_inc)
@@ -15,7 +15,7 @@ fn sum<1>(a: u64) -> u64
   join_phi = phi(final, zero_idx, red_add)
   in_bounds = lt(idx_inc, bound)
   if = if(inner_side_effect, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   final = region(guard_false, if_false)
-  r = return(final, join_phi)
\ No newline at end of file
+  r = return(final, join_phi)
diff --git a/hercules_test/test_inputs/loop_analysis/do_loop_no_guard.hir b/hercules_test/test_inputs/loop_analysis/do_loop_no_guard.hir
index 9e22e14b..d48fe062 100644
--- a/hercules_test/test_inputs/loop_analysis/do_loop_no_guard.hir
+++ b/hercules_test/test_inputs/loop_analysis/do_loop_no_guard.hir
@@ -10,6 +10,6 @@ fn sum<1>(a: u64) -> u64
   red_add = add(red, one_idx)
   in_bounds = lt(idx_inc, bound)
   if = if(inner_side_effect, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red_add)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red_add)
diff --git a/hercules_test/test_inputs/loop_analysis/do_while_separate_body.hir b/hercules_test/test_inputs/loop_analysis/do_while_separate_body.hir
index 42269040..435b6268 100644
--- a/hercules_test/test_inputs/loop_analysis/do_while_separate_body.hir
+++ b/hercules_test/test_inputs/loop_analysis/do_while_separate_body.hir
@@ -11,6 +11,6 @@ fn sum<1>(a: i32) -> u64
   red_add = add(outer_red, idx)
   in_bounds = lt(idx_inc, bound)
   if = if(inner_region, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, inner_red)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, inner_red)
diff --git a/hercules_test/test_inputs/loop_analysis/do_while_separate_body2.hir b/hercules_test/test_inputs/loop_analysis/do_while_separate_body2.hir
index a751952d..d1e2d4d6 100644
--- a/hercules_test/test_inputs/loop_analysis/do_while_separate_body2.hir
+++ b/hercules_test/test_inputs/loop_analysis/do_while_separate_body2.hir
@@ -13,6 +13,6 @@ fn sum<1>(a: i32) -> u64
   red_mul = mul(red_add, idx)
   in_bounds = lt(idx_inc, bound)
   if = if(inner_region, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, inner_red)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, inner_red)
diff --git a/hercules_test/test_inputs/loop_analysis/loop_array_sum.hir b/hercules_test/test_inputs/loop_analysis/loop_array_sum.hir
index f9972b59..884d22d4 100644
--- a/hercules_test/test_inputs/loop_analysis/loop_array_sum.hir
+++ b/hercules_test/test_inputs/loop_analysis/loop_array_sum.hir
@@ -11,6 +11,6 @@ fn sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red)
diff --git a/hercules_test/test_inputs/loop_analysis/loop_body_count.hir b/hercules_test/test_inputs/loop_analysis/loop_body_count.hir
index c6f3cbf6..5ec745ba 100644
--- a/hercules_test/test_inputs/loop_analysis/loop_body_count.hir
+++ b/hercules_test/test_inputs/loop_analysis/loop_body_count.hir
@@ -11,6 +11,6 @@ fn loop<1>(a: u64) -> u64
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, var)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, var)
diff --git a/hercules_test/test_inputs/loop_analysis/loop_sum.hir b/hercules_test/test_inputs/loop_analysis/loop_sum.hir
index fd9c4deb..a236ddf7 100644
--- a/hercules_test/test_inputs/loop_analysis/loop_sum.hir
+++ b/hercules_test/test_inputs/loop_analysis/loop_sum.hir
@@ -11,6 +11,6 @@ fn loop<1>(a: u32) -> i32
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, var)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, var)
diff --git a/hercules_test/test_inputs/loop_analysis/loop_trip_count.hir b/hercules_test/test_inputs/loop_analysis/loop_trip_count.hir
index b756f090..799cc6d9 100644
--- a/hercules_test/test_inputs/loop_analysis/loop_trip_count.hir
+++ b/hercules_test/test_inputs/loop_analysis/loop_trip_count.hir
@@ -12,8 +12,8 @@ fn loop<1>(b: prod(u64, u64)) -> prod(u64, u64)
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   tuple1 = write(c, var, field(0))
   tuple2 = write(tuple1, idx, field(1))
-  r = return(if_false, tuple2)
\ No newline at end of file
+  r = return(if_false, tuple2)
diff --git a/hercules_test/test_inputs/loop_analysis/loop_trip_count_tuple.hir b/hercules_test/test_inputs/loop_analysis/loop_trip_count_tuple.hir
index b756f090..799cc6d9 100644
--- a/hercules_test/test_inputs/loop_analysis/loop_trip_count_tuple.hir
+++ b/hercules_test/test_inputs/loop_analysis/loop_trip_count_tuple.hir
@@ -12,8 +12,8 @@ fn loop<1>(b: prod(u64, u64)) -> prod(u64, u64)
   idx_inc = add(idx, one_idx)
   in_bounds = lt(idx, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   tuple1 = write(c, var, field(0))
   tuple2 = write(tuple1, idx, field(1))
-  r = return(if_false, tuple2)
\ No newline at end of file
+  r = return(if_false, tuple2)
diff --git a/hercules_test/test_inputs/simple2.hir b/hercules_test/test_inputs/simple2.hir
index af5ac284..d4f1bebe 100644
--- a/hercules_test/test_inputs/simple2.hir
+++ b/hercules_test/test_inputs/simple2.hir
@@ -8,6 +8,6 @@ fn simple2(x: i32) -> i32
   fac_acc = mul(fac, idx_inc)
   in_bounds = lt(idx_inc, x)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, fac_acc)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, fac_acc)
diff --git a/hercules_test/test_inputs/strset.hir b/hercules_test/test_inputs/strset.hir
index 4c8b32ee..e8615f21 100644
--- a/hercules_test/test_inputs/strset.hir
+++ b/hercules_test/test_inputs/strset.hir
@@ -12,6 +12,6 @@ fn strset<1>(str: array(u8, #0), byte: u8) -> array(u8, #0)
   continue = ne(read, byte)
   if_cond = and(continue, in_bounds)
   if = if(loop, if_cond)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   r = return(if_false, str_inc)
diff --git a/hercules_test/test_inputs/sum_int1.hir b/hercules_test/test_inputs/sum_int1.hir
index 4a9ba015..7de8cf1e 100644
--- a/hercules_test/test_inputs/sum_int1.hir
+++ b/hercules_test/test_inputs/sum_int1.hir
@@ -11,6 +11,6 @@ fn sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read)
   in_bounds = lt(idx_inc, bound)
   if = if(loop, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
-  r = return(if_false, red_add)
\ No newline at end of file
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
+  r = return(if_false, red_add)
diff --git a/hercules_test/test_inputs/sum_int2.hir b/hercules_test/test_inputs/sum_int2.hir
index b5e9a5c0..bc614d4e 100644
--- a/hercules_test/test_inputs/sum_int2.hir
+++ b/hercules_test/test_inputs/sum_int2.hir
@@ -11,8 +11,8 @@ fn alt_sum<1>(a: array(i32, #0)) -> i32
   rem = rem(idx, two_idx)
   odd = eq(rem, one_idx)
   negate_if = if(loop, odd)
-  negate_if_false = projection(negate_if, 0)
-  negate_if_true = projection(negate_if, 1)
+  negate_if_false = control_projection(negate_if, 0)
+  negate_if_true = control_projection(negate_if, 1)
   negate_bottom = region(negate_if_false, negate_if_true)
   read = read(a, position(idx))
   read_neg = neg(read)
@@ -20,6 +20,6 @@ fn alt_sum<1>(a: array(i32, #0)) -> i32
   red_add = add(red, read_phi)
   in_bounds = lt(idx_inc, bound)
   if = if(negate_bottom, in_bounds)
-  if_false = projection(if, 0)
-  if_true = projection(if, 1)
+  if_false = control_projection(if, 0)
+  if_true = control_projection(if, 1)
   r = return(if_false, red_add)
-- 
GitLab