[llvm] [NVPTX] Skip processing BasicBlocks with single unreachable instruction in `nvptx-lower-unreachable` pass. (PR #72641)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 12:31:45 PST 2024
================
@@ -138,7 +138,19 @@ bool NVPTXLowerUnreachable::runOnFunction(Function &F) {
InlineAsm *Exit = InlineAsm::get(ExitFTy, "exit;", "", true);
bool Changed = false;
- for (auto &BB : F)
+
+ // In scenarios where a BasicBlock contains only one unreachable instruction,
+ // the joint action of nvptx-isel and unreachable-mbb-elimination
+ // effectively optimizes the BasicBlock out. However, adding an exit
+ // command to such a BasicBlock, as suggested by this pass, preserves it
+ // within the Control Flow Graph (CFG), thereby negatively impacting size and
+ // performance. To counteract this undesirable consequence, we choose to
+ // refrain from processing BasicBlocks with just one unreachable instruction
+ // in this pass.
+
----------------
Artem-B wrote:
I'm not sure what kind of input you're still looking for. I'm not disputing that you see a performance regression, but I still do not think it warrants disabling lowering of unreachable to exit.
I remain open to re-introduction of a hidden option to allow disabling it, as an escape hatch.
If you can figure out why a seemingly minor differences result in such a huge performance difference and if there's something we can do to improve the code, without risking correctness, that would be helpful.
https://github.com/llvm/llvm-project/pull/72641
More information about the llvm-commits
mailing list