1*06c3fb27SDimitry Andric //===- AMDGPUUnifyDivergentExitNodes.h ------------------------------------===// 2*06c3fb27SDimitry Andric // 3*06c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*06c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*06c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*06c3fb27SDimitry Andric // 7*06c3fb27SDimitry Andric //===----------------------------------------------------------------------===// 8*06c3fb27SDimitry Andric // 9*06c3fb27SDimitry Andric // This is a variant of the UnifyFunctionExitNodes pass. Rather than ensuring 10*06c3fb27SDimitry Andric // there is at most one ret and one unreachable instruction, it ensures there is 11*06c3fb27SDimitry Andric // at most one divergent exiting block. 12*06c3fb27SDimitry Andric // 13*06c3fb27SDimitry Andric // StructurizeCFG can't deal with multi-exit regions formed by branches to 14*06c3fb27SDimitry Andric // multiple return nodes. It is not desirable to structurize regions with 15*06c3fb27SDimitry Andric // uniform branches, so unifying those to the same return block as divergent 16*06c3fb27SDimitry Andric // branches inhibits use of scalar branching. It still can't deal with the case 17*06c3fb27SDimitry Andric // where one branch goes to return, and one unreachable. Replace unreachable in 18*06c3fb27SDimitry Andric // this case with a return. 19*06c3fb27SDimitry Andric // 20*06c3fb27SDimitry Andric //===----------------------------------------------------------------------===// 21*06c3fb27SDimitry Andric 22*06c3fb27SDimitry Andric #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUUNIFYDIVERGENTEXITNODES_H 23*06c3fb27SDimitry Andric #define LLVM_LIB_TARGET_AMDGPU_AMDGPUUNIFYDIVERGENTEXITNODES_H 24*06c3fb27SDimitry Andric 25*06c3fb27SDimitry Andric #include "AMDGPU.h" 26*06c3fb27SDimitry Andric 27*06c3fb27SDimitry Andric namespace llvm { 28*06c3fb27SDimitry Andric class AMDGPUUnifyDivergentExitNodesPass 29*06c3fb27SDimitry Andric : public PassInfoMixin<AMDGPUUnifyDivergentExitNodesPass> { 30*06c3fb27SDimitry Andric public: 31*06c3fb27SDimitry Andric PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 32*06c3fb27SDimitry Andric }; 33*06c3fb27SDimitry Andric 34*06c3fb27SDimitry Andric } // end namespace llvm 35*06c3fb27SDimitry Andric 36*06c3fb27SDimitry Andric #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUUNIFYDIVERGENTEXITNODES_H 37