From 0bcdf93009233ea2522ce6d4c36013bd89d81532 Mon Sep 17 00:00:00 2001 From: Aaron Councilman <aaronjc4@illinois.edu> Date: Wed, 20 Nov 2024 19:28:57 -0600 Subject: [PATCH] Delete selects --- hercules_opt/src/sroa.rs | 1 + hercules_samples/products.hir | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/hercules_opt/src/sroa.rs b/hercules_opt/src/sroa.rs index 6205421f..afbc775b 100644 --- a/hercules_opt/src/sroa.rs +++ b/hercules_opt/src/sroa.rs @@ -412,6 +412,7 @@ pub fn sroa(editor: &mut FunctionEditor, reverse_postorder: &Vec<NodeID>, types: }, ); }); + to_delete.push(node); } else { worklist.push_back(WorkItem::AllocatedTernary { cond, diff --git a/hercules_samples/products.hir b/hercules_samples/products.hir index d09bb0fa..9d191beb 100644 --- a/hercules_samples/products.hir +++ b/hercules_samples/products.hir @@ -1,3 +1,23 @@ -fn test(x : prod(i32, f32), y: prod(i32, f32), b: bool) -> prod(i32, f32) - res = select(b, x, y) - r = return(start, res) +fn test(x : prod(i32, f32), b: bool) -> prod(i32, f32) + zero = constant(u64, 0) + one = constant(i32, 1) + two = constant(u64, 2) + three = constant(f32, 3.0) + + f_ctrl = fork(start, 10) + idx = thread_id(f_ctrl, 0) + + mod2 = rem(idx, two) + is_even = eq(mod2, zero) + field0 = read(res, field(0)) + field1 = read(res, field(1)) + add = add(field0, one) + mul = mul(field1, three) + upd0 = write(res, add, field(0)) + upd1 = write(res, mul, field(1)) + select = select(is_even, upd0, upd1) + + j_ctrl = join(f_ctrl) + res = reduce(j_ctrl, x, select) + + r = return(j_ctrl, res) -- GitLab