From a0e4871ba2db347eb4b757615fc54e32376efaa5 Mon Sep 17 00:00:00 2001 From: xumingkuan Date: Tue, 9 Jun 2020 10:59:23 -0400 Subject: [PATCH] [IR] Move "lower_access" to after "offload" (#1194) --- taichi/transforms/compile_to_offloads.cpp | 38 +++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/taichi/transforms/compile_to_offloads.cpp b/taichi/transforms/compile_to_offloads.cpp index 8fd785b632902..33476411ae25e 100644 --- a/taichi/transforms/compile_to_offloads.cpp +++ b/taichi/transforms/compile_to_offloads.cpp @@ -85,24 +85,10 @@ void compile_to_offloads(IRNode *ir, print("Access flagged I"); irpass::analysis::verify(ir); - if (lower_global_access) { - irpass::lower_access(ir, true); - print("Access lowered"); - irpass::analysis::verify(ir); - - irpass::die(ir); - print("DIE"); - irpass::analysis::verify(ir); - } - irpass::full_simplify(ir); print("Simplified II"); irpass::analysis::verify(ir); - irpass::flag_access(ir); - print("Access flagged II"); - irpass::analysis::verify(ir); - irpass::constant_fold(ir); print("Constant folded"); @@ -110,9 +96,21 @@ void compile_to_offloads(IRNode *ir, print("Offloaded"); irpass::analysis::verify(ir); - if (!lower_global_access) { + irpass::flag_access(ir); + print("Access flagged II"); + irpass::analysis::verify(ir); + + if (lower_global_access) { + irpass::lower_access(ir, true); + print("Access lowered"); + irpass::analysis::verify(ir); + + irpass::die(ir); + print("DIE"); + irpass::analysis::verify(ir); + irpass::flag_access(ir); - print("Access flagged after offloading"); + print("Access flagged III"); irpass::analysis::verify(ir); } @@ -123,6 +121,12 @@ void compile_to_offloads(IRNode *ir, print("Atomics demoted"); irpass::analysis::verify(ir); + irpass::full_simplify(ir); + print("Simplified III"); + + irpass::extract_constant(ir); + print("Constant extracted III"); + irpass::variable_optimization(ir, true); print("Store forwarded II"); @@ -131,7 +135,7 @@ void compile_to_offloads(IRNode *ir, irpass::analysis::verify(ir); irpass::full_simplify(ir); - print("Simplified III"); + print("Simplified IV"); // Final field registration correctness & type checking irpass::typecheck(ir);