From 63c9cc566c857c5ba5d8b0c3cd22b568d6ba87cb Mon Sep 17 00:00:00 2001 From: Ruobing Han Date: Fri, 23 Sep 2022 09:15:10 -0400 Subject: [PATCH] avoid unnecessary extend arrays --- .../KernelTranslation/src/x86/insert_warp_loop.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compilation/KernelTranslation/src/x86/insert_warp_loop.cpp b/compilation/KernelTranslation/src/x86/insert_warp_loop.cpp index 95ef901..0819dcf 100644 --- a/compilation/KernelTranslation/src/x86/insert_warp_loop.cpp +++ b/compilation/KernelTranslation/src/x86/insert_warp_loop.cpp @@ -76,7 +76,7 @@ int need_nested_loop; // adding multiple kenerl in file support -bool ShouldNotBeContextSaved(llvm::Instruction *instr) { +bool ShouldNotBeContextSaved(llvm::Instruction *instr, DivergenceInfo &DI) { if (isa(instr)) return true; @@ -91,9 +91,7 @@ bool ShouldNotBeContextSaved(llvm::Instruction *instr) { if (load_addr == M->getGlobalVariable("warp_vote")) return true; } - // TODO: we should further analyze whether the local variable - // is same among all threads within a wrap - return false; + return !DI.isDivergent(*instr); } // generate countpart alloc in the beginning of the Function @@ -394,7 +392,7 @@ void handle_local_variable_intra_warp(std::vector PRs, for (llvm::BasicBlock::iterator instr = bb->begin(); instr != bb->end(); ++instr) { llvm::Instruction *instruction = &*instr; - if (ShouldNotBeContextSaved(instruction)) + if (ShouldNotBeContextSaved(instruction, DI)) continue; for (Instruction::use_iterator ui = instruction->use_begin(), ue = instruction->use_end();