[llvm] [Uniformity] Implement per-output machine uniformity analysis (PR #179275)
Petar Avramovic via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 6 02:19:50 PST 2026
================
@@ -10671,23 +10639,40 @@ SIInstrInfo::getGenericInstructionUniformity(const MachineInstr &MI) const {
if (Opcode == TargetOpcode::G_ADDRSPACE_CAST)
return HandleAddrSpaceCast(MI);
- if (auto *GI = dyn_cast<GIntrinsic>(&MI)) {
- auto IID = GI->getIntrinsicID();
- if (AMDGPU::isIntrinsicSourceOfDivergence(IID))
- return InstructionUniformity::NeverUniform;
+ if (const GIntrinsic *GI = dyn_cast<GIntrinsic>(&MI)) {
+ Intrinsic::ID IID = GI->getIntrinsicID();
+ if (AMDGPU::isIntrinsicSourceOfDivergence(IID)) {
+ // Some intrinsics produce multiple outputs with mixed uniformity.
+ // For these, we need to check DefIdx to determine which output is being
+ // queried and return the appropriate uniformity.
+ switch (IID) {
+ case Intrinsic::amdgcn_if:
+ case Intrinsic::amdgcn_else:
----------------
petar-avramovic wrote:
> I am not sure why uniformity needs to track the semantic distinction between "lane mask i64" vs "regular uniform i64". I think it would be much better if we keep uniformity analysis focused on its core purpose.
Getting back to my original question, who uses **machine** uniformity info?
Tracking Registers instead of MachineInstr does not bring anything new. One user is GlobalISel and it needs to special case those "lane mask i64" vs "regular uniform i64".
The registers that might "change" result with switching to tracking Registers still need to be special case tracked by GlobalISel.
https://github.com/llvm/llvm-project/pull/179275
More information about the llvm-commits
mailing list