diff --git a/llvm/include/llvm/ADT/GenericSSAContext.h b/llvm/include/llvm/ADT/GenericSSAContext.h --- a/llvm/include/llvm/ADT/GenericSSAContext.h +++ b/llvm/include/llvm/ADT/GenericSSAContext.h @@ -53,20 +53,36 @@ // indicated by the compiler. using FunctionT = typename _FunctionT::invalidTemplateInstanceError; - // Every FunctionT has a unique BlockT marked as its entry. - // - // static BlockT* getEntryBlock(FunctionT &F); - // Initialize the SSA context with information about the FunctionT being // processed. // // void setFunction(FunctionT &function); // FunctionT* getFunction() const; + // Every FunctionT has a unique BlockT marked as its entry. + // + // static BlockT* getEntryBlock(FunctionT &F); + + // Methods to examine basic blocks and values + // + // static void appendBlockDefs(SmallVectorImpl &defs, + // BlockT &block); + // static void appendBlockDefs(SmallVectorImpl &defs, + // const BlockT &block); + + // static void appendBlockTerms(SmallVectorImpl &terms, + // BlockT &block); + // static void appendBlockTerms(SmallVectorImpl &terms, + // const BlockT &block); + // + // static bool comesBefore(const InstT *lhs, const InstT *rhs); + // static bool isConstantOrUndefValuePhi(const InstT &Instr); + // const BlockT *getDefBlock(const ValueRefT value) const; + // Methods to print various objects. // // Printable print(BlockT *block) const; - // Printable print(InstructionT *inst) const; + // Printable print(InstT *inst) const; // Printable print(ValueRefT value) const; }; } // namespace llvm diff --git a/llvm/include/llvm/ADT/GenericUniformityImpl.h b/llvm/include/llvm/ADT/GenericUniformityImpl.h --- a/llvm/include/llvm/ADT/GenericUniformityImpl.h +++ b/llvm/include/llvm/ADT/GenericUniformityImpl.h @@ -963,7 +963,7 @@ LLVM_DEBUG(dbgs() << "taintAndPushPhiNodes in " << Context.print(&JoinBlock) << "\n"); for (const auto &Phi : JoinBlock.phis()) { - if (ContextT::isConstantValuePhi(Phi)) + if (ContextT::isConstantOrUndefValuePhi(Phi)) continue; if (markDivergent(Phi)) Worklist.push_back(&Phi); diff --git a/llvm/include/llvm/CodeGen/MachineSSAContext.h b/llvm/include/llvm/CodeGen/MachineSSAContext.h --- a/llvm/include/llvm/CodeGen/MachineSSAContext.h +++ b/llvm/include/llvm/CodeGen/MachineSSAContext.h @@ -58,7 +58,7 @@ static void appendBlockTerms(SmallVectorImpl &terms, const MachineBasicBlock &block); MachineBasicBlock *getDefBlock(Register) const; - static bool isConstantValuePhi(const MachineInstr &Phi); + static bool isConstantOrUndefValuePhi(const MachineInstr &Phi); Printable print(const MachineBasicBlock *Block) const; Printable print(const MachineInstr *Inst) const; diff --git a/llvm/include/llvm/IR/SSAContext.h b/llvm/include/llvm/IR/SSAContext.h --- a/llvm/include/llvm/IR/SSAContext.h +++ b/llvm/include/llvm/IR/SSAContext.h @@ -63,7 +63,7 @@ const BasicBlock &block); static bool comesBefore(const Instruction *lhs, const Instruction *rhs); - static bool isConstantValuePhi(const Instruction &Instr); + static bool isConstantOrUndefValuePhi(const Instruction &Instr); const BasicBlock *getDefBlock(const Value *value) const; Printable print(const BasicBlock *Block) const; diff --git a/llvm/lib/CodeGen/MachineSSAContext.cpp b/llvm/lib/CodeGen/MachineSSAContext.cpp --- a/llvm/lib/CodeGen/MachineSSAContext.cpp +++ b/llvm/lib/CodeGen/MachineSSAContext.cpp @@ -56,7 +56,7 @@ return RegInfo->getVRegDef(value)->getParent(); } -bool MachineSSAContext::isConstantValuePhi(const MachineInstr &Phi) { +bool MachineSSAContext::isConstantOrUndefValuePhi(const MachineInstr &Phi) { return Phi.isConstantValuePHI(); } diff --git a/llvm/lib/IR/SSAContext.cpp b/llvm/lib/IR/SSAContext.cpp --- a/llvm/lib/IR/SSAContext.cpp +++ b/llvm/lib/IR/SSAContext.cpp @@ -75,9 +75,9 @@ return lhs->comesBefore(rhs); } -bool SSAContext::isConstantValuePhi(const Instruction &Instr) { +bool SSAContext::isConstantOrUndefValuePhi(const Instruction &Instr) { if (auto *Phi = dyn_cast(&Instr)) - return Phi->hasConstantValue(); + return Phi->hasConstantOrUndefValue(); return false; } diff --git a/llvm/test/Analysis/DivergenceAnalysis/AMDGPU/phi-undef.ll b/llvm/test/Analysis/DivergenceAnalysis/AMDGPU/phi-undef.ll --- a/llvm/test/Analysis/DivergenceAnalysis/AMDGPU/phi-undef.ll +++ b/llvm/test/Analysis/DivergenceAnalysis/AMDGPU/phi-undef.ll @@ -1,15 +1,14 @@ -; RUN: opt -mtriple amdgcn-- -passes='print' -disable-output %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LOOPDA -; RUN: opt -mtriple amdgcn-- -passes='print' -disable-output %s 2>&1 | FileCheck %s --check-prefixes=CHECK,CYCLEDA +; RUN: opt -mtriple amdgcn-- -passes='print' -disable-output %s 2>&1 | FileCheck %s +; RUN: opt -mtriple amdgcn-- -passes='print' -disable-output %s 2>&1 | FileCheck %s ; CHECK-LABEL: 'test1': ; CHECK: DIVERGENT: i32 %bound -; CYCLEDA: DIVERGENT: %counter = -; LOOPDA: {{^ *}} %counter = -; CHECK-NEXT: DIVERGENT: %break = icmp sge i32 %counter, %bound -; CYCLEDA: DIVERGENT: %counter.next = -; CYCLEDA: DIVERGENT: %counter.footer = -; LOOPDA: {{^ *}}%counter.next = -; LOOPDA: {{^ *}}%counter.footer = +; CHECK: {{^ *}} %counter = +; CHECK: DIVERGENT: %break = icmp sge i32 %counter, %bound +; CHECK: DIVERGENT: br i1 %break, label %footer, label %body +; CHECK: {{^ *}}%counter.next = +; CHECK: {{^ *}}%counter.footer = +; CHECK: DIVERGENT: br i1 %break, label %end, label %header ; Note: %counter is not divergent!