Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp =================================================================== --- llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -10872,7 +10872,15 @@ // uniform values (as produced by the mask results of control flow intrinsics) // used outside of divergent blocks. The phi users need to also be treated as // always uniform. -static bool hasCFUser(const Value *V, SmallPtrSet &Visited) { +static bool hasCFUser(const Value *V, SmallPtrSet &Visited, + unsigned WaveSize) { + // FIXME: We asssume we never cast the mask results of a control flow + // intrinsic. + // Early exit if the type won't be consistent as a compile time hack. + IntegerType *IT = dyn_cast(V->getType()); + if (!IT || IT->getBitWidth() != WaveSize) + return false; + if (!isa(V)) return false; if (!Visited.insert(V).second) @@ -10904,7 +10912,7 @@ } } } else { - Result = hasCFUser(U, Visited); + Result = hasCFUser(U, Visited, WaveSize); } if (Result) break; @@ -10944,5 +10952,5 @@ } } SmallPtrSet Visited; - return hasCFUser(V, Visited); + return hasCFUser(V, Visited, Subtarget->getWavefrontSize()); }